p***@gmail.com
2014-10-16 14:18:32 UTC
SET @Query = 'SET NOCOUNT ON;
SELECT ''"[N Number]"''
, ''"[AE Diagnosis Group Name]"''
, ''"[GP Code]"''
, ''"[GP Name]"''
, ''"[Attendance]"''
UNION ALL
SELECT ''"'' + CONVERT(varchar(150), [N Number] ) + ''"''
, ''"'' + CONVERT(varchar(150), [AE Diagnosis Group Name] ) + ''"''
, ''"'' + CONVERT(varchar(150), [GP Code] ) + ''"''
, ''"'' + CONVERT(varchar(150), [GP Name] ) + ''"''
, ''"'' + CONVERT(varchar(150), [Attendance] ) + ''"''
FROM ##EmailTable2
WHERE PracticeCode = ''' + (SELECT [PracticeCode] FROM ##EmailTable WHERE ID = @i) + ''';'
SELECT ''"[N Number]"''
, ''"[AE Diagnosis Group Name]"''
, ''"[GP Code]"''
, ''"[GP Name]"''
, ''"[Attendance]"''
UNION ALL
SELECT ''"'' + CONVERT(varchar(150), [N Number] ) + ''"''
, ''"'' + CONVERT(varchar(150), [AE Diagnosis Group Name] ) + ''"''
, ''"'' + CONVERT(varchar(150), [GP Code] ) + ''"''
, ''"'' + CONVERT(varchar(150), [GP Name] ) + ''"''
, ''"'' + CONVERT(varchar(150), [Attendance] ) + ''"''
FROM ##EmailTable2
WHERE PracticeCode = ''' + (SELECT [PracticeCode] FROM ##EmailTable WHERE ID = @i) + ''';'