Question : SQL Select Statement

My attached statement(s) work fine...except there are times when there is no email in r_users.

When the useremail in r_users returns a null or '', how can I set the default to '[email protected]'  ?
1:
2:
3:
4:
5:
6:
declare @dealID int
set @dealID = 1413
declare @rep nvarchar(20)
set @rep = (select rep from crmprod_01.dbo.p_deals where dealID = @dealID)
declare @toEmail nvarchar(100)
set @toEmail = (select useremail from r_users where username= @rep)

Answer : SQL Select Statement

sure:

declare @dealID int
set @dealID = 1413
declare @rep nvarchar(20)
set @rep = (select rep from crmprod_01.dbo.p_deals where dealID = @dealID)
declare @toEmail nvarchar(100)
set @toEmail = ISNULL((select nullif(useremail, '') from r_users where username= @rep), '[email protected]')
Random Solutions  
 
programming4us programming4us