日期:2014-05-18 浏览次数:21123 次
if object_id('tb') is not null drop table tb go create table tb(id int,name1 varchar(50),name2 varchar(50)) insert into tb select 1,'aaa','呵呵' insert into tb select 1,'aaabbbb','呵呵' insert into tb select 1,'a','呵呵' select id,name1+replicate(' ',(select top 1 len(name1)+2 from tb order by len(name1) desc)-datalength(name1))+name2 as name from tb --或 select id,name1+replicate(' ',10-datalength(name1))+name2 as name from tb