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
 SQL Server Development (2000)
 It is possible using CASE statement in INSERT

Author  Topic 

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2008-11-29 : 23:16:05
Me using SQL Server 2000. It is possible using CASE statement in INSERT statement? Did anyone have a success sample?

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2008-11-29 : 23:44:57
You can just change this, which will fail
INSERT mytable (col1, col2)
VALUES (CASE WHEN @a = @b THEN @c ELSE @d END, 'other value')

to this, which will work
INSERT mytable (col1, col2)
SELECT CASE WHEN @a = @b THEN @c ELSE @d END, 'other value'
Go to Top of Page
   

- Advertisement -