 |
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

February 9th, 2011, 08:30 PM
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
What is wrong with this statmet?
Hi,
update tabheader
set unitid = null, updatedBy = (CASE WHEN headerId = 36959 THEN 1)
The error says:
Line 2: Incorrect syntax near ')'.
The updatedBy is of type int.
Thank you,
|

February 10th, 2011, 03:53 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Your CASE statement is missing an END statement. Also, you're missing an ELSE clause so when headerId is not 36959, it ends up as null. Is that by design?
Imar
|
The Following User Says Thank You to Imar For This Useful Post:
|
rupen (February 10th, 2011)
|

February 10th, 2011, 01:16 PM
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
yes, that's it, it was missing END. Though else was there but I removed it for the sake of simplicity as the real query is long enough.
Thank you again Imar.
|

February 10th, 2011, 01:39 PM
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
hey, sorry to bang again.. this gives error as syntax error near 'or'.
Code:
update tabheader
set unitid = null, updatedBy = (CASE WHEN headerId = 36959 THEN 1
when headerId in (338 , 339 or 19126 or 29909 or 29934 or 29935 or 29938 or 30968 or 37647 or 37648) then null
else 2 end)
|

February 10th, 2011, 03:55 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
This doesn't look right:
338 , 339 or 19126 or 29909
You should be using commas to separate values in an IN clause.
Cheers,
Imar
|
The Following User Says Thank You to Imar For This Useful Post:
|
rupen (February 10th, 2011)
|

February 10th, 2011, 06:48 PM
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
alright..done.
|
|
 |