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 |
emmim44
Yak Posting Veteran
65 Posts |
Posted - 2012-07-13 : 03:54:57
|
I am getting a syntax err. Can anyone point it out? @username is an optional variable. Msg 156, Level 15, State 1, Line 64Incorrect syntax near the keyword 'case'. where ---OperationType = 'U' dwo.operationDate between convert(varchar,@sDate,1) and convert(varchar,@eDate,1) (case when @userName <>'' then And p.CentralAccount = @userName else end) And dwo.ObjectKey = ( select XObjectKey |
|
sql-programmers
Posting Yak Master
190 Posts |
Posted - 2012-07-13 : 04:20:26
|
I think Logical operators missedwhere ---OperationType = 'U'dwo.operationDate between convert(varchar,@sDate,1) and convert(varchar,@eDate,1)(AND / OR)(case when @userName <>'' then And p.CentralAccount = @userName else end)SQL Server Programmers and Consultantshttp://www.sql-programmers.com/ |
 |
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 2012-07-13 : 04:26:04
|
quote: Originally posted by sql-programmers I think Logical operators missedwhere ---OperationType = 'U'dwo.operationDate between convert(varchar,@sDate,1) and convert(varchar,@eDate,1)(AND / OR)(case when @userName <>'' then And p.CentralAccount = @userName else end)SQL Server Programmers and Consultantshttp://www.sql-programmers.com/
I dont think so... I am already including "And p.CentralAccount = @userName " |
 |
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 2012-07-13 : 04:38:43
|
it is solved...Solution is: And p.CentralAccount = (case when @userName <>'' then @userName else p.CentralAccount end)Thank you all. |
 |
|
|
|
|
|
|