Geef de kolomnamen door als parameters
DECLARE @COLS NVARCHAR(MAX)
DECLARE @TABLE NVARCHAR(MAX)
SET @COLS = 'COL1,COL2'
SET @TABLE = 'TABLENAME'
Voer nu de query uit
DECLARE @QRY NVARCHAR(MAX)
SET @QRY = 'SELECT (SELECT '[email protected]+' FROM '[email protected]+') FROM sourcetable'
EXEC SP_EXECUTESQL @QRY