Click here to Skip to main content
15,923,087 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have the following code, I want to find a way to execute the code in the [Code] field. I wish I could use a Function but it would require Dynamic SQL and I wish I could call a stored proc in the Select statement but I can't do that either. I need to avoid doing a Loop since there will be hundreds of these records.

SELECT Coverage, N'SELECT ' + ISNULL(Limit COLLATE SQL_Latin1_General_CP1_CI_AS, '''''')     + N',' + 
    ISNULL(Deductible COLLATE SQL_Latin1_General_CP1_CI_AS, '''''') + N',' + 
    ISNULL(Premium COLLATE SQL_Latin1_General_CP1_CI_AS, '''''') + 
    N' FROM PHI_PIJ.dbo.ASBYCPP' + N' WHERE ' + PolicyNum COLLATE SQL_Latin1_General_CP1_CI_AS +
    N' = ' + QUOTENAME('BOP000249316', '''')  + N' AND BYAOTX' + N'=' + QUOTENAME(Coverage COLLATE SQL_Latin1_General_CP1_CI_AS, '''')
FROM PHI_PIJ.dbo.ASBYCPP
INNER JOIN PolicySummary.dbo.Coverage
    ON Coverage = BYAOTX
    AND LOB = 'BOP'
WHERE  BYARTX + BYASTX + BYADNB = 'BOP000059311'


An example of what is in [Code] field is:
SELECT '','',BYA3VA FROM PHI_PIJ.dbo.ASBYCPP WHERE BYARTX+BYASTX+BYADNB = 'BOP000249316' AND BYAOTX='BASIC'
Posted
Comments
j snooze 2-Apr-14 17:49pm    
What would be an example of how you want the final data to look?
Maciej Los 3-Apr-14 17:21pm    
Please, be more specific and provide more details. Sample data might be helpfull.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900