Friday, February 17, 2012

empty status of a variable

The example bellow will receive a parameter.

create procedure usp_InsertProducts
@.SKU varchar(30)

Now how do I check whether is @.SKU empty or not.

Your help is kindly appreciated.

Regards

Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***> how do I check whether is @.SKU empty or not.

IF @.sku IS NULL ...

or

IF @.sku = '' ...

depending on what you mean by "empty".

To differentiate between a NULL and no value specified you could
provide a default using some invalid token to represent the missing
value:

CREATE PROCEDURE usp_InsertProducts
@.sku VARCHAR(30) = '<Unspecified>'
AS ...

IF @.sku = '<Unspecified>'
...

--
David Portas
SQL Server MVP
--

No comments:

Post a Comment