惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
I
InfoQ
博客园_首页
G
Google Developers Blog
爱范儿
爱范儿
Last Week in AI
Last Week in AI
量子位
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
月光博客
月光博客
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - skyfei

Xcode 文档注释方法 查看iOS模拟器应用的沙箱文件 Show in Finder OC代码 C# x86应用x64系统上读取x64位应用的注册表 Make webclient support upload the large file which are larger than 1G Shortcut key for WPF get Android information with adb, the build version Decodes a QuotedPrintable encoded string C# USB Detection - winform and WPF [转] 线程同步 C# 常见面试题(2) 转:C# Interview Questions Openxml: 导出excel 设置 cell的格式 - skyfei OpenXML: excel 插入BarChart图表 OpenXML: Asp.net利用OpenXML 导出Excel. 'String or binary data would be truncated' error message .net Create Excel 2007 file with open xml 利用.Net Framework2.0 zip压缩、解压 string 数据 C#中文和UNICODE字符转换方法 - skyfei - 博客园
TRIGGERS :Cannot use text, ntext, or image columns in the...
skyfei · 2008-11-28 · via 博客园 - skyfei

我本想利用SQL Server的Trigger来保存被删除的数据:

create TRIGGER [mytable_delete_backup]
   ON  [dbo].[mytable]
   AFTER delete
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    insert into mytable_bak select * from deleted

END

很不幸, 其中一个表里有NText 列, 结果遇到了标题的错误, 赶紧google一下, 没有什么好的解决方案,只能从比的地方下手, 而且有的人说trigger在多行处理上不稳定, 于是我就寻找在其他方法, 起初想用先用 insert .. select 方法,再delete, 但我的数据库上千万条数据, 这样做显然效率太低了。 最后想到用 delete output 方法:

DELETE FROM table1 OUTPUT DELETED.* INTO table2 WHERE id in ( 2, 3)

不过 output 有个小问题, 那就是 id 在table 1 中是identify (自增列)   在导入的表table2 中 必须将id 设为非自增的, 否则会报错。