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.
| Author |
Topic |
|
gregoryagu
Yak Posting Veteran
80 Posts |
Posted - 2008-07-21 : 15:33:33
|
| This does not compile:Declare @ret intSelect @ret = EXISTS(Select * from aTable))The only way I have found is like this: IF (EXISTS (SELECT * FROM aTable )) SELECT @ret = 1 ELSE SELECT @ret = 0 but I was trying to not use an IF construct.Thanks,Greg |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-07-21 : 16:05:56
|
| That is correct. EXISTS() can be used in boolean expressions only, and in SQL Server boolean expressions and "normal" expressions are two different things and cannot be implicitly converted back and forth.i.e., you cannot write:declare @b bitset @b = (1 > 2)as in other languages; you must write:declare @b bitset @b = case when 1 > 2 then 1 else 0 end- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
gregoryagu
Yak Posting Veteran
80 Posts |
Posted - 2008-07-21 : 16:52:00
|
| OK, I get it now. Thanks.Greg |
 |
|
|
|
|
|