用相等的空格连接两列

时间:2011-02-10 18:17:35

标签: sql-server sql-server-2008

修改

SELECT  (dbo.County.CountyName + ' (' + dbo.State.StateName + ' ) ') 
AS CountyName from Table1

我为一个例子添加了两列:

CountyName + '(' + StateName + ')'

如何确保或具有固定的CountyName宽度,使其看起来整洁/干净

举个例子:

Torrance     (California)
Torrance     (Chicago)
Cook         (Chicago)
....

1 个答案:

答案 0 :(得分:1)

select CountyName + space(20-len(CountyName)) + '(' + StateName + ')'...