michael
michael

Reputation: 39

Stored procedure not null and not empty or space

I try to use stored procedure in my project.However i have question about null and empty.

ALTER PROCEDURE [dbo].[SP_EMAIL_LIST]
AS
BEGIN
SELECT *
FROM CUSTOMER
WHERE
EMAIL_ADRESS IS NOT NULL       
END

I used where clause for avoid getting values null or empty values however i still get null values.

How can i get email adress values if not null and not empty ?

Upvotes: 0

Views: 2049

Answers (1)

SchmitzIT
SchmitzIT

Reputation: 9552

This should work.

 SELECT 
     *
 FROM 
     CUSTOMER
 WHERE
     EMAIL_ADRESS IS NOT NULL AND EMAIL_ADRESS != ''

Keep in mind there is a difference between NULL and ''. '' is simply an empty string. NULL generally is used to indicate an unknown or unspecified value.

Upvotes: 1

Related Questions