| Author |
Topic  |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/13/2012 : 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 64 Incorrect 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
USA
189 Posts |
Posted - 07/13/2012 : 04:20:26
|
I think Logical operators missed
where ---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 Consultants http://www.sql-programmers.com/ |
 |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/13/2012 : 04:26:04
|
quote: Originally posted by sql-programmers
I think Logical operators missed
where ---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 Consultants http://www.sql-programmers.com/
I dont think so... I am already including "And p.CentralAccount = @userName " |
 |
|
|
emmim44
Yak Posting Veteran
65 Posts |
Posted - 07/13/2012 : 04:38:43
|
it is solved...Solution is: And p.CentralAccount = (case when @userName <>'' then @userName else p.CentralAccount end)
Thank you all. |
 |
|
| |
Topic  |
|