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.
| Author |
Topic |
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2011-08-12 : 14:29:23
|
| Not sure how to do this. I am passing a var to the stored proc. Question is in the code belowSELECT dbo.offender.sid, dbo.offendercontact.offenderid, CONVERT(VARCHAR, dbo.offendercontact.action_due_datetime, 101) AS action_due_datetime, dbo.offender.firstname, dbo.offender.lastname, dbo.offendercontact.username, dbo.users.firstname + ' ' + dbo.users.lastname AS usernamefull FROM dbo.offendercontact LEFT OUTER JOIN dbo.users ON dbo.offendercontact.username = dbo.users.username LEFT OUTER JOIN dbo.offender ON dbo.offendercontact.offenderid = dbo.offender.offenderid WHERE ( dbo.offendercontact.comment_action_lkp_id = 2 ) I am passing in a boolean var "@dateAfter"if it is true I have to add the and.... for the Getdate()so like if @dateAfter = False then ....do this====> AND ( dbo.offendercontact.action_due_datetime < Getdate() ) ''''Below stays AND ( dbo.offendercontact.username IN ( @UserName ) ) ORDER BY dbo.offendercontact.action_due_datetimeDaveHelixpoint Web Developmenthttp://www.helixpoint.com |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-08-12 : 14:35:02
|
This?AND ( (@dateAfter = False and dbo.offendercontact.action_due_datetime < Getdate()) OR @dateAfter = True ) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|