首页 > 解决方案 > 使用 SSMS 查询窗口执行大批量插入

问题描述

如果没有人/没有其他人正在访问系统,是否可以通过执行写入 SQL 查询窗口的一堆 INSERTS 来执行大批量、顺序插入,如下所示?

我在一组考试和分数插入中对其进行了测试,并且它有效。

(1 row affected)
(1 row affected)

但我不确定它是否会导致在查询窗口中一次执行所有这些问题。

或者这会导致问题吗?

--insert exam
INSERT INTO exam.exam (id, title) VALUES (NEXT VALUE FOR exam.nextid, 'Myth & Legends');

--insert score using the 'id' above
INSERT INTO exam.scores(examId, baseUrl, assessmentSize, tag)
    SELECT current_value , 
    'https://storage.googleapis.com/school-assessments', 
    101,
    'Myth & Legends' 
    FROM sys.sequences WHERE schema_id = 9

--insert exam
INSERT INTO exam.exam (id, title) VALUES (NEXT VALUE FOR exam.nextid, 'Political Abstraction');

--insert score using the 'id' above
INSERT INTO exam.scores(examId, baseUrl, assessmentSize, tag)
    SELECT current_value,
    'https://storage.googleapis.com/school-assessments',
    101, 
   'Political Abstraction'
    FROM sys.sequences WHERE schema_id = 9

标签: sqlsql-serversql-server-2012ssms

解决方案


推荐阅读