关于SQL SERVER里处理字符串的问题
begin
declare @strUserId varchar(50)
set @strUserId=''
select @strUserId=@strUserId+','+cast(StudentID as varchar) from StudentInfo
select @strUserId
end
这样输出的结果如: ,2345,6789,8765,2342,
------解决方案--------------------
begin
declare @strUserId varchar(50)
select @strUserId=ISNULL(@strUserId+',','')+cast(StudentID as varchar) from StudentInfo
WHERE LEN(StudentID )>0
select @strUserId
end