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 |
crosurfer
Starting Member
2 Posts |
Posted - 2008-05-09 : 07:38:01
|
Hi,Im trying to put a select statement into select case.Something like this:select case @typewhen 'A' then (select * from table1)when 'B' then (select * from table2)when 'C' then (select * from table3)end But i get this error: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.Is it possible to do this? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-09 : 07:43:23
|
IF @Type = 'A' SELECT * FROM Table1IF @Type = 'B' SELECT * FROM Table2IF @Type = 'C' SELECT * FROM Table3 E 12°55'05.25"N 56°04'39.16" |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-09 : 07:43:32
|
Use IF or if your table structures are similar then use UNION ALL.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
crosurfer
Starting Member
2 Posts |
Posted - 2008-05-09 : 08:10:16
|
quote: Originally posted by Peso IF @Type = 'A' SELECT * FROM Table1IF @Type = 'B' SELECT * FROM Table2IF @Type = 'C' SELECT * FROM Table3 E 12°55'05.25"N 56°04'39.16"
Thank you. |
 |
|
|
|
|