troubleshooting Question

SQL string from 3 cases

Avatar of Larry Brister
Larry BristerFlag for United States of America asked on
Microsoft SQL Server 2008Microsoft SQL Server.NET Programming
10 Comments1 Solution370 ViewsLast Modified:
I have a function that is working and builds a string that is returned

What I need is to build a string that reads

'Error: Invalid '  And whichever variable or variables are = 'N'

Example...If all are invalid or = 'N'

@Output = 'Invalid or missing policyNumber,  IssuerName, CADate'

If ONLY CADate is invalid
@Output = 'Invalid or missing CADate'

ALTER FUNCTION [dbo].[uf_ucc_structured_WithCA] (@DealID int) 

	Declare @policyNumber varchar(40)
	Declare @IssuerName varchar(100)
	Declare @CADate varchar(30)
	Select	@policyNumber = x.AnnnuitantPolicyNumber,
			@IssuerName   = x.IssuerName,
			@CADate		  = x.EventDate	   
			From	( Select IsNull(pd.AnnuitantPolicyNumber,'N') AnnnuitantPolicyNumber
						,IsNull(i.IssuerName, 'N') IssuerName
						,case when pe.[EventData] is null then 'N' else dbo.FormatDateTime(pe.[EventData], 'STANDARD') end eventDate
						 from crmprod_01.dbo.P_Deals pd 
								left join proc_ss.dbo.p_issuers i on pd.IssuerID = i.IssuerID
								left join crmprod_01.dbo.p_Events_Table pe on (pd.DealID = pe.dealID  and pe.EventTypeID = 84)
								where pd.DealID =@dealID) x
	DECLARE @Output VARCHAR(8000)
		SET		@Output =	@policyNumber + ' , ' + @IssuerName + ' , ' + @CADate
	RETURN @Output

Open in new window

Ephraim Wangoya
Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros