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)
 select case

Author  Topic 

ilimax
Posting Yak Master

164 Posts

Posted - 2008-06-13 : 15:11:12
Is there in Transact-SQL something like SELECT CASE in VB or SWITCH in C#.

I would like to make stored procedure where I receive paramater then continue ....
Something like this

CREATE PROCEDURE SelectMyCase
@bla int
SELECT CASE @bla
Case 0
Update Table1 ...
Case 1
Update Table2
Case 2
Insert into table3
END SELECT





tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-13 : 15:12:53
You'll need to use IF/ELSE.

CASE in T-SQL is for individual queries.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-13 : 15:14:00
You should use IF ELSE

IF condition 1
Statement 1
ESLE IF condition 1
Statement 2
ELSE
Statement 3



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ilimax
Posting Yak Master

164 Posts

Posted - 2008-06-13 : 15:59:45
Thanks
Go to Top of Page
   

- Advertisement -