Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to learn case statements
Message
From
28/03/2005 10:51:37
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00999435
Message ID:
00999441
Views:
20
Thank you very much
Jim

>Jim,
>
>The CASE in T-SQL is a finction not the flow control statement. For the flow control you would use IF ELSE statrement as shown below
>
IF @BOOK = 'ALL' 	BEGIN
>	IF (@Type = 'ALL')  THEN
>			BEGIN	
>					PRINT 'ALL Skus, ALL Types'
>	END	
>
>	ELSE IF (@Type IN ('ntrReceipt','Trans','SC' )  OR @TYPE2 IN ('ntrTransfe','ntrReceipt','SP') )THEN
>					BEGIN
>						PRINT 'All SKUs, Receipt, Receipt'
>					END
>									
>	ELSE IF (@TYPE = '2') THEN
>					BEGIN
>						PRINT ' All SKU''s, @Type = 2'
>						END
>	END
>
>END
>
>ELSE
>...
In the future please enclouse code between < pre> and < /pre> tags (w/o spaces) for readability.
>
>
>>I did read BOL
>>
>>
>>I would like to simplify a complexed stored procedure useing CASE Statements
>>The following code gives me the following errors.
>>
><snip>
Previous
Reply
Map
View

Click here to load this message in the networking platform