Multiple Insert statements in one connection

前端 未结 4 1716
南旧
南旧 2021-01-24 00:05

I need some tips on how to do this better, I am inserting multiple queries with using one connection.

I understand this is not good programming, especi

4条回答
  •  [愿得一人]
    2021-01-24 00:38

    UNION your SELECT statements together to insert multiple rows into the same table.

    INSERT INTO dbo.Products (ID, [Name])
    SELECT 1, 'Car'
    UNION ALL
    SELECT 2, 'Boat'
    UNION ALL
    SELECT 3, 'Bike'
    

提交回复
热议问题