34,593
社区成员
发帖
与我相关
我的任务
分享
if object_id('tb','U') is not null
drop table tb
go
create table tb
(
id int,
name varchar(10)
)
go
insert into tb select 1,'1234567890'
go
update tb set name=left(name,5) --把列数据更新成长度为5的字符串
alter table tb alter column name varchar(5) --更改列长度
update tb set a=left(a,5) where len(a)=datalength(a) and len(a)>5
alter table tb alter column a varchar(5)
Update t1
Set Col=left(Col,5)
Where len(Col)>5
Alter table t1
Alter Column Col varchar(5)