日期:2014-05-18 浏览次数:20495 次
declare @表tbl table (name varchar(10),cn varchar(10)) insert into @表tbl select 'fda,o',null union all select 'aa,o=',null union all select 'bb,3,o',null update @表tbl set cn=left(name,charindex(',o',name)-1) select * from @表tbl /* name cn ---------- ---------- fda,o fda aa,o= aa bb,3,o bb,3 */
------解决方案--------------------
update t set cn=substring(name,1,charindex(',o',name)-1)
------解决方案--------------------
update tb set cn=substring(name,1,charindex(',o',name)-1) where charindex(',o',name) > 0