SQLTeam.com | Weblogs | Forums

Reference Syntax From Another Query

I have a basic insert select query we will refer to this as query1. I have a check and balance test query template I will refer to as testquery I use to check for duplicate keys from my other query. I have to copy the select key from query1 and paste it into my testquery to ensure no duplicate keys have been created. Is there anyway I could make this dynamic in some way where all I would do is call the open query or enter the query name?

Why do you have to cut and paste to a test query to insure no dups? The first query returns all records that have more that 1 entry? Why do you even need to concatenate to find the duplicate values, seems like c.CardCode will work. If you provide DDL, sample data and expected results, we can probably help you further