Insert multiple rows WITHOUT repeating the “INSERT INTO …” part of the statement?

前端 未结 15 1892
广开言路
广开言路 2020-11-22 09:16

I know I\'ve done this before years ago, but I can\'t remember the syntax, and I can\'t find it anywhere due to pulling up tons of help docs and articles about \"bulk import

15条回答
  •  灰色年华
    2020-11-22 09:32

    I've been using the following:

    INSERT INTO [TableName] (ID, Name)
    values (NEWID(), NEWID())
    GO 10
    

    It will add ten rows with unique GUIDs for ID and Name.

    Note: do not end the last line (GO 10) with ';' because it will throw error: A fatal scripting error occurred. Incorrect syntax was encountered while parsing GO.

提交回复
热议问题