【问题标题】:How to Write statement to delete in batches of 1000如何编写语句以批量删除 1000
【发布时间】:2019-10-02 18:34:42
【问题描述】:

下面是需要重写的代码,以便批量删除 1000 个,因为这里的代码会导致我们的表格膨胀。

目标: 重写job里面的delete语句,批量1000条删除

@command=N'exec system.dbo.sp_global_SQLExec_RunOnAllCompanies ''delete from alohaftplog where date < convert(varchar(15),getdate() -30,101)''',

【问题讨论】:

  • sp_global_SQLExec_RunOnAllCompanies的定义是什么?
  • 存储的过程通过表中的公司运行。

标签: .net sql-server tsql


【解决方案1】:

可以在删除语句中添加TOP 1000:

delete TOP 1000 from alohaftplog where date < convert(varchar(15),getdate() -30,101)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-28
    • 1970-01-01
    • 2020-03-15
    • 1970-01-01
    • 2017-05-25
    • 1970-01-01
    • 2017-09-23
    相关资源
    最近更新 更多