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
 inserting conditions in stored procedures

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2007-06-12 : 03:06:39
How to insert if-else statements to my stored procedure if i am only going to set a condition on a single column of the table?

Ex. SELECT a.m0020_pat_id, a.M0040_PAT_LNAME + ', ' + a.M0040_PAT_FNAME + ' ' + a.M0040_PAT_MI as patientName,
a.M0030_START_CARE_DT as socdate, M0906_DC_TRAN_DTH_DT as transferdate,M0906_DC_TRAN_DTH_DT+14 as DueDate, M0230_PRIMARY_DIAG_ICD, c.[description] AS M0230_PRIMARY_DIAG_DESC,
d.name facilityName, e.FacilityTypeName,a.EffectiveDate_End

( i will specify that if MO906_DC_TRAN_DTH+14 is greater than EffectiveDate_End THEN MO906_DC_TRAN_DTH+14=EffectiveDate_end)


shemay

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-06-12 : 08:13:29
I am not quite sure exactly what you need, but look into CASE expressions in books on-line.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -