我需要将SQL脚本作为作业运行,我希望它在计划时运行两次。我怎么能在下面的脚本上做到这一点。
IF EXISTS (SELECT name FROM sysindexes
WHERE name = 'IgnoreList_Specification')
DROP INDEX IgnoreList.IgnoreList_Specification
GO
CREATE INDEX IgnoreList_Specification ON IgnoreList
(Specification)
WITH FILLFACTOR = 90 ON [PRIMARY]
GO
IF EXISTS (SELECT name FROM sysindexes
WHERE name = 'IgnoreList_Custom')
DROP INDEX IgnoreList.IgnoreList_Custom
GO
CREATE INDEX IgnoreList_Custom ON IgnoreList
(Custom)
WITH FILLFACTOR = 90 ON [PRIMARY]
GO
IF EXISTS (SELECT name FROM sysindexes
WHERE name = 'IgnoreList_Custom1')
DROP INDEX IgnoreList.IgnoreList_Custom1
GO
CREATE INDEX IgnoreList_Custom1 ON IgnoreList
(Custom1)
WITH FILLFACTOR = 90 ON [PRIMARY]
GO
答案 0 :(得分:1)
对于要运行两次的每个批次,请使用GO 2.这将执行批次两次
https://msdn.microsoft.com/en-us/library/ms188037.aspx
如果要运行整个作业两次,可以安排一个在另一个完成后运行,或者只是复制步骤。