第一个问题把数据保存到htmldata2中 在表htmldata上建触发器 CREATE TRIGGER [htmldata_Insert] ON [dbo].[htmldata] FOR INSERT AS insert into htmldata2 select * from inserted 如果需要处理(建议不要把<>和中间的内容去掉,因为这样可能把内容一样去掉,可以把<>替换掉) 可以这样 CREATE TRIGGER [htmldata_Insert] ON [dbo].[htmldata] FOR INSERT AS insert into htmldata2 select id,url,title,replace(replace(replace(html,'&','&'),'<','<'),'>','>') from inserted 在读出来的时候在作相反的替换
To gongshutao(虫虫) :好像语法有错误,说identity_insert为on时才能为标志列指定显示式,而且insert不能为text类型,什么办?
TO www_bestofbest(天之骄子) 你的htmldata2的字段id也是自动增长的对不对? 可以这样 CREATE TRIGGER [htmldata_Insert] ON [dbo].[htmldata] FOR INSERT AS insert into htmldata2(url,title,html) select url,title,replace(replace(replace(html,'&','&'),'<','<'),'>','>') from inserted
说的触发器是指你在向HTMLDATA表中插入数据的时候可以同时更新HTMLDATA2表,实现两个表的数据同步,对你的内容过滤是没什么帮助的!还有一点不明白的就是如果你的网页结构很复杂,把HTML标签都去掉了,然后保存它的内容用什么用?如果想再对这个内容进行重新编辑的话,你如何定位这些内容呢?
在表htmldata上建触发器
CREATE TRIGGER [htmldata_Insert] ON [dbo].[htmldata]
FOR INSERT
AS
insert into htmldata2 select * from inserted
如果需要处理(建议不要把<>和中间的内容去掉,因为这样可能把内容一样去掉,可以把<>替换掉)
可以这样
CREATE TRIGGER [htmldata_Insert] ON [dbo].[htmldata]
FOR INSERT
AS
insert into htmldata2 select id,url,title,replace(replace(replace(html,'&','&'),'<','<'),'>','>') from inserted
在读出来的时候在作相反的替换
http://www.csdn.net/expert/topic/701/701403.xml?temp=.7961542
你的htmldata2的字段id也是自动增长的对不对?
可以这样
CREATE TRIGGER [htmldata_Insert] ON [dbo].[htmldata]
FOR INSERT
AS
insert into htmldata2(url,title,html) select url,title,replace(replace(replace(html,'&','&'),'<','<'),'>','>') from inserted
那不能用Replace,我以为是VarChar呢,我看看还有没有别的办法。