T-SQL固定宽度输出

Jim*_*ner 1 t-sql sql-server sql-server-2005

有没有办法让SQL Server输出固定宽度的字符串?例如

SELECT FixedWidth(cola, 7), FixedWidth(colb, 10) ...
Run Code Online (Sandbox Code Playgroud)

那会分别输出7个和10个字符的2个字符串吗?就像是

'test   ' 'foobar    '
'aabbb  ' 'hello     '
'foo    ' 'bar       '
Run Code Online (Sandbox Code Playgroud)

Mar*_*ith 5

  SELECT 
       CAST(cola as char(7)) as cola, 
       CAST(colb as char(10)) as colb ....
Run Code Online (Sandbox Code Playgroud)