Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 debug -- if

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2006-05-28 : 13:53:39
can someone help me fix this statement in correct sql syntax -- what I want to do is check the entry and if the value of isdouble=1 then I want to set valid=0

thanks

if select isdouble from entries where id=@id=1 then select @valid=0

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-05-28 : 20:32:43
Ur requirement is not clear enough!!

What is "entry" ?
What do u mean by "set valid=0" ?

R u talking about variables or data in fields or both?
Is this a part of a program or T-SQL code ?

The condition "where id=1" returns only one record ?


Srinika
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-05-28 : 23:17:42
read case in BOL...

also you can't combine data retrieval and variable assignment

--------------------
keeping it simple...
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-29 : 00:06:20
[code]if (select isdouble from entries where id = @id) = 1 select @valid=0[/code]

Note : you will encounter error if select isdouble from entries where id = @id returns more than one row.


KH

Go to Top of Page

cmdr_skywalker
Posting Yak Master

159 Posts

Posted - 2006-05-29 : 01:09:48
if you have more than one record and one record is enough, use this:
if (select top 1 isdouble from entries where id = @id) = 1 select @valid=0
or
if (select isnull(count(isdouble),0) from entries where id = @id)> 0 select @valid=0



May the Almighty God bless us all!
Go to Top of Page
   

- Advertisement -