Tuesday, March 27, 2012

case statement

How do i update a column using case statement.

I have a column that has values from 1 to 5.

I wanna update it like: case 1 then change the value to xyz

case 2 then change the value to abc

can anyone help me with the script?

thanks

Not sure whether you are looking for sql command to do this or looking to do this in SSIS ? The sql command to do this would be something like this:

update Table

set column = case when column = 1 then xyz

when column = 2 then abc

end

In SSIS, you can use an execute sql task with a similar command as above.

|||Thanks. this is what i need. i was using the case statement incorrectly.sql

No comments:

Post a Comment