1.事务(基本)
GO BEGIN TRY BEGIN TRAN -- 导入数据 COMMIT TRAN END TRY BEGIN CATCH ROLLBACK TRAN END CATCH GO
2.替换ntext,text。ntext不能直接使用replace函数,所以要转化为nvarchar(max),nvarchar(max)可以存储2G的东西,可以满足一般的需求。
update dbo.News set ContentText=replace(convert(nvarchar(max),ContentText),'/www/','/NewsTxt/')
从左到右分别是: 外键约束名,子表名,外键列名,父表名
select fk.name fkname , ftable.name ftablename, cn.name fkcol, rtable.name ftablename from sysforeignkeys
join sysobjects fk
on sysforeignkeys.constid = fk.id
join sysobjects ftable
on sysforeignkeys.fkeyid = ftable.id
join sysobjects rtable
on sysforeignkeys.rkeyid = rtable.id
join syscolumns cn
on sysforeignkeys.fkeyid = cn.id and sysforeignkeys.fkey = cn.colid
select fk.name fkname , ftable.name ftablename, cn.name fkcol, rtable.name ftablename from sysforeignkeys
join sysobjects fk
on sysforeignkeys.constid = fk.id
join sysobjects ftable
on sysforeignkeys.fkeyid = ftable.id
join sysobjects rtable
on sysforeignkeys.rkeyid = rtable.id
join syscolumns cn
on sysforeignkeys.fkeyid = cn.id and sysforeignkeys.fkey = cn.colid
原文地址:http://chenjianjx.iteye.com/blog/222267