Created
January 19, 2022 07:36
-
-
Save kwestground/6ea6bb4c301c4c0c0b9cfa033c50ba20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Table nvarchar(100) = 'MyTableName' | |
SELECT 'REPLACE(''INSERT INTO ['+@Table+'] (' + | |
STUFF (( | |
SELECT ', [' + name + ']' | |
FROM syscolumns | |
WHERE id = OBJECT_ID(@Table) AND | |
name <> 'me' | |
FOR XML PATH('')), 1, 1, '') + | |
') VALUES (' + | |
STUFF (( | |
SELECT | |
'] AS nvarchar(MAX)), ''NULL'') + '''''', '''''' + ISNULL(CAST([' + name | |
FROM syscolumns | |
WHERE id = OBJECT_ID(@Table) AND | |
name <> 'me' | |
FOR XML PATH('')), 1, LEN('] AS nvarchar(MAX)), ''NULL'') + '''''', '), '') + '] AS nvarchar(MAX)), ''NULL'') + '''''')'', ''''''NULL'''''', ''NULL'')' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment