Return string if NULL in T-SQL

tsc

n00b
Joined
Jan 9, 2010
Messages
3
Hi all. This is my first post to this forum. Go easy on me ;-)

I'm trying to return a result even if NULL as a string of results that are delimited. Apparently if one of the results are NULL, the entire thing is NULL. I haven't found anything yet to force a return of nothing. I'm sure this is probubly simple to do... I just haven't found it yet. Anyone?

Example:

SELECT (edocHeader + '_|_' + CAST(edocDate AS varchar) + '_|_' + edocDescrip + '_|_' + edocDep) AS DBDATA
FROM tbl_Docs Left Join tbl_Docs_Edit ON docEdit = edocID
WHERE docID = 2805 AND tID = 3

Although edocDate has data, I wanted the following "_|_1/1/2010_|_" and instead I get "NULL"

Thanks!
 
Is edocDate column actually a DateTime column?
 
try this

SELECT (
isnull(edocHeader,'') + '_|_' +
isnull(CAST(edocDate AS varchar),'') + '_|_' +
isnull(edocDescrip,'') + '_|_' +
isnull(edocDep,'')) AS DBDATA
FROM tbl_Docs Left Join tbl_Docs_Edit ON docEdit = edocID
WHERE docID = 2805 AND tID = 3
 
Back
Top