日期:2014-05-18  浏览次数:20491 次

如何通过存储过程把含有关键字“苹果”的文章的类别字段标志为1,含有“镜子”的文章的类别字段标志为为2?
如何通过存储过程把含有关键字“苹果”的文章的类别字段标志为1,含有“镜子”的文章的类别字段标志为为2,如此类推。。。?

------解决方案--------------------
create proc sp_update
as

set xact_abort on

begin tran

update 表名 set 类别 = 1 where 文章内容字段 like '%苹果% '

update 表名 set 类别 = 2 where 文章内容字段 like '%镜子% '


commit tran

return 0

------解决方案--------------------
create proc p_TEST
as
UPDATE yTABLE SET TYPE = 1 WHERE CHARINDEX( '苹果 ',yCOL) > 0
UPDATE yTABLE SET TYPE = 2 WHERE CHARINDEX( '镜子 ',yCOL) > 0

GO

------解决方案--------------------
create procedure P
as
update table set type = 1 where *** like '$苹果$ '
update table set type = 2 where *** like '$镜子$ '
go