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
 General SQL Server Forums
 New to SQL Server Programming
 Using If Statement

Author  Topic 

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2008-05-18 : 04:17:22
May I know how to use If statement in T-SQL?

I have a condition where

field = if the value1 >= 500 then field =500 else field = field

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-18 : 05:28:59
you need to use case here

i.e
field=case when value>=500 then 500 else field end
Go to Top of Page

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2008-05-18 : 05:43:17
many thanks I got it already..
I just used

'field' = when 'field2' >= 500 then 500 when field2 < 500 then field2 end


Go to Top of Page
   

- Advertisement -