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
 General SQL Server Forums
 New to SQL Server Programming
 Changing table to select from with SQL

Author  Topic 

ducletan
Starting Member

25 Posts

Posted - 2010-12-15 : 04:00:49
In sql server 205.i want
SELECT *
FROM
CASE @brcd
WHEN '1' THEN Table_1
WHEN '2' THEN Table_2
ELSE Table_X
END

or

case @brcd
WHEN '1' THEN select * from Table_1
WHEN '2' THEN select * form Table_2
ELSE select * Table_X
END



Help me

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-15 : 05:43:16
That's possible with dynamic SQL:
http://www.sommarskog.se/dynamic_sql.html


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -