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 |
|
logjam
Starting Member
2 Posts |
Posted - 2004-02-07 : 20:31:37
|
| I need to know how I would do the SQL equivalent of a VBScript Select/Case block. I do know about the SQL command "CASE WHEN" but that only lets me define the value of a variable. I'm trying to do something like below:SELECT CASE @storecodeCASE 1INSERT INTO table1 ...CASE 2INSERT INTO table2 ...CASE 3...END SELECTHow can I do this with SQL commands? |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2004-02-07 : 21:11:25
|
| You have to do this with a bunch of IF statements. There isn't an equiviant of that style case/switch block on TSQL.Damian |
 |
|
|
logjam
Starting Member
2 Posts |
Posted - 2004-02-07 : 21:42:04
|
| Thanks for the reply. Is there anything proprietary to MS-SQL that could do this? |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2004-02-07 : 21:47:28
|
| Nope.You just have to write IF statements. TSQL is a better set language than it is for control of flow.Damian |
 |
|
|
|
|
|