1

嗨,我想打印类似的东西

                I will start from there 
test this phrase

所以我做了以下

declare @x varchar(max)
select @x = LEFT(' '+'I will start from there',LEN('test this phrase')+ LEN('I will start from there'))+ CHAR(10) + 'test this phrase'

print @x 

输出是

 I will start from there
test this phrase

第一行不是从第二行的开头开始的,left应该可以解决问题,但不确定出了什么问题

4

1 回答 1

2

尝试使用SPACE功能如下

declare @x varchar(100)
select @x = LEFT(SPACE(LEN('test this phrase')+1)+'I will start from there',LEN('test this phrase')+ LEN('I will start from there'))+ CHAR(10) + 'test this phrase'

print @x 
于 2013-09-12T11:24:32.743 回答