{{theTime}}

Search This Blog

Total Pageviews

Generate Insert Sql from Select Statement

SELECT 'INSERT INTO ReferenceTable (ID, Name) VALUES (' +
       CAST(ID AS NVARCHAR) + ', ''' + Name + ''');'
FROM ReferenceTable
FOR XML PATH('');

No comments:

Generate Insert Sql from Select Statement

SELECT 'INSERT INTO ReferenceTable (ID, Name) VALUES (' +        CAST(ID AS NVARCHAR) + ', ''' + Name + ''...