Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select if not null

Status
Not open for further replies.

AndreAraujo

Programmer
Feb 14, 2002
62
PT
Hi, i have this stored procedure to return only values that are not null
Code:
CREATE PROCEDURE list_serie 
AS
SELECT Num, Line, 
case Serie (isnull(serie,'') then '' else 'serie:' + serie, case Ref (isnull(ref,'') then '' else ' ref:' + ref,
case Marca (isnull(marca,'') then '' else 'marca:' + marca
FROM tbl_serie
i get error "incorrect syntax near the keyword then"

the idea is to return values that are not null, this sp is used in a crystal report , so when all values are null i supress the section.
Any ideas??
Thanks in advance

Andre
 
try
Code:
CREATE PROCEDURE list_serie 
AS
SELECT Num, Line, 
case WHEN Serie IS NULL then '' else 'serie:' + serie end, 
case WHEN Ref IS NULL then '' else ' ref:' + ref end,
case WHEN Marca IS NULL then '' else 'marca:' + marca end
FROM tbl_serie


"I'm living so far beyond my income that we may almost be said to be living apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top