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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
博客园_首页
雷峰网
雷峰网
V
Visual Studio Blog
爱范儿
爱范儿
A
About on SuperTechFans
量子位
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
S
SegmentFault 最新的问题
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 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 设为非自增的, 否则会报错。