sqlserver 字符串连接的问题
declare @a varchar, @i int
set @a = 'a'
set @i = 0
while (@i < 10)
begin
set @a= @a + convert(varchar, @i)
set @i = @i + 1
end
select @a
如上代码,希望利用循环来连接字符,结果是'',而不是想要的'a0123456789',
请问如何修改才能得到'a0123456789'
[解决办法]
declare @a varchar(max), @i int
set @a = 'a'
set @i = 0
while (@i < 10)
begin
set @a= @a + convert(varchar, @i)
set @i = @i + 1
end
select @a