Home > Archive > Microsoft SQL Server forum > July 2005 > empty status of a variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author empty status of a variable
Eugene Anthony

2005-07-19, 1:23 pm

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.droptable.com ***
David Portas

2005-07-19, 1:23 pm

> 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
--

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com