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

前端 未结 15 2042
广开言路
广开言路 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:40

    You could do this (ugly but it works):

    INSERT INTO dbo.MyTable (ID, Name) 
    select * from
    (
     select 123, 'Timmy'
      union all
     select 124, 'Jonny' 
      union all
     select 125, 'Sally'
     ...
    ) x
    

提交回复
热议问题