Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to learn case statements
Message
 
 
À
28/03/2005 10:35:03
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00999435
Message ID:
00999438
Vues:
27
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>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform