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)
 how to upadate a table with if else check

Author  Topic 

AsimKhaliq
Yak Posting Veteran

94 Posts

Posted - 2003-12-05 : 17:37:10
Hi

I want to upate my table according to a given condition based on some select statement. So if a field validate then the fields (more then one) will be added with some specific value abut if not than will be entered with other value.

I need the syntex, caz i really dont know how to use upate, select and if toghter.

Thanks

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2003-12-05 : 17:55:25
Have a look at the CASE statement in BOL.
update <table>
set <column> = CASE
WHEN <given condition> THEN <some specific value>
ELSE <other value>
END


Go to Top of Page
   

- Advertisement -