是長度超過12的數據,只保留前面12個字符,後面的都不要,是這個意思不?如果是的話,如果你是要查詢Select Left(ColName, 12) As ColName From TableName 如果你是要更新Update TableName Set ColName = Left(ColName, 12)
看來你要的是這個Update TableName Set ColName = Left(ColName, 12)
create table #t1 (g1 char(2), g2 varchar(100))insert into #t1 select 'a','我们2g的中国人' union all select 'b','来到春天gh'select g1,g2 from #t1select g1,left(g2,5) from #t1 =================== 结果:(所影响的行数为 2 行)g1,g2 a ,我们2g的中国人 b ,来到春天gh(所影响的行数为 2 行)g1, a ,我们2g的 b ,来到春天g(所影响的行数为 2 行)
如果你是要更新Update TableName Set ColName = Left(ColName, 12)
(g1 char(2),
g2 varchar(100))insert into #t1
select 'a','我们2g的中国人'
union all select 'b','来到春天gh'select g1,g2 from #t1select g1,left(g2,5)
from #t1
===================
结果:(所影响的行数为 2 行)g1,g2
a ,我们2g的中国人
b ,来到春天gh(所影响的行数为 2 行)g1,
a ,我们2g的
b ,来到春天g(所影响的行数为 2 行)