IIS ASP - setting variable in query

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > August 2005 > setting variable in query





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author setting variable in query
Joey Martin

2005-08-22, 2:49 am

I have a sql query that runs on my asp page.

select
contactname,contactnumber,contactnumber1
,contactemail,address,city,state
,zip,type,sqft,0,bedrooms,baths,lotsize,
acreage,garage,comments,price,0,
0,county from table1 where active='Y'

I need HASPHOTO to equal 1 if hasphoto <> 0 and HASPHOTO=0 when
hasphoto=0. Make sense? HASPHOTO usually equals a number, but in this
case, I want it to equal a 1 or 0 because I am exporting this to a CSV
file. I know how to do everything else, just not this part.

Thanks in advance.

*** Sent via Developersdex http://www.codecomments.com ***
Bob Barrows [MVP]

2005-08-22, 7:49 am

Joey Martin wrote:
> I have a sql query that runs on my asp page.
>
> select
> contactname,contactnumber,contactnumber1
,contactemail,address,city,state
> ,zip,type,sqft,0,bedrooms,baths,lotsize,
acreage,garage,comments,price,0,
> 0,county from table1 where active='Y'
>
> I need HASPHOTO to equal 1 if hasphoto <> 0 and HASPHOTO=0 when
> hasphoto=0. Make sense?


Not really. Is hasphoto a column in your table? What is its datatype?

> HASPHOTO usually equals a number, but in this
> case, I want it to equal a 1 or 0 because I am exporting this to a CSV
> file. I know how to do everything else, just not this part.
>
> Thanks in advance.


What database? Type and version, please.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Joey Martin

2005-08-22, 7:49 am

This is a SQL 2K server. HASPHOTOS is an int field. It is one of the
columns in my table.


*** Sent via Developersdex http://www.codecomments.com ***
Bob Barrows [MVP]

2005-08-22, 7:49 am

Joey Martin wrote:
> This is a SQL 2K server. HASPHOTOS is an int field. It is one of the
> columns in my table.
>
>


SELECT ...,
CASE HASPHOTOS WHEN 0 THEN 0 ELSE 1 END [HASPHOTOS]
....

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com