Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
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
 
Old February 9th, 2011, 08:30 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default 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,
 
Old February 10th, 2011, 03:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
rupen (February 10th, 2011)
 
Old February 10th, 2011, 01:16 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

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.
 
Old February 10th, 2011, 01:39 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

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)
 
Old February 10th, 2011, 03:55 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
rupen (February 10th, 2011)
 
Old February 10th, 2011, 06:48 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

alright..done.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this worded wrong or am I reading wrong? notig BOOK: Beginning Visual C# 2010 1 September 25th, 2010 01:51 PM
What's wrong here? nero XSLT 4 October 3rd, 2007 03:42 PM
Don't know where have gone wrong hoailing22 ASP.NET 1.0 and 1.1 Basics 1 May 20th, 2005 07:06 AM
what's wrong with this? gilgalbiblewheel Classic ASP Databases 2 August 17th, 2004 07:22 PM
Right or wrong? ÕÅÃÍ C++ Programming 6 February 27th, 2004 02:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.