declare @str varchar(2000)
declare @i int
set @i = 1
set @str=''SELECT @str=@str+cast((@i+1) as CHAR(1))+isnull(tm.sAnswer,'')
FROM tbAnswer t
left outer join dbo.tbPollMyAnswer tm on tm.iAnswerId=t.iAnswerId
WHERE t.iQuestionID=12 and tm.sAnswer is not null
print @str如上
想加一个 序号,1,2,3,4......
大神们给点指点
declare @i int
set @i = 1
set @str=''SELECT @str=@str+cast((@i+1) as CHAR(1))+isnull(tm.sAnswer,'')
FROM tbAnswer t
left outer join dbo.tbPollMyAnswer tm on tm.iAnswerId=t.iAnswerId
WHERE t.iQuestionID=12 and tm.sAnswer is not null
print @str如上
想加一个 序号,1,2,3,4......
大神们给点指点
DECLARE @str VARCHAR(2000)
DECLARE @i INT
SET @i = 1
SET @str = ''
SELECT @str = @str+ ROW_NUMBER()OVER(ORDER BY tm.sAnswer ) AS RID, + ISNULL(tm.sAnswer, '')
FROM tbAnswer t
LEFT OUTER JOIN dbo.tbPollMyAnswer tm ON tm.iAnswerId = t.iAnswerId
WHERE t.iQuestionID = 12
AND tm.sAnswer IS NOT NULL
PRINT @str
declare @i int
set @i = 1
set @str=''
SELECT @str=@str+cast((@i+1) as CHAR(1))+isnull(tm.sAnswer,''),num=rownumber()over(order by getdate())
FROM tbAnswer t
left outer join dbo.tbPollMyAnswer tm on tm.iAnswerId=t.iAnswerId
WHERE t.iQuestionID=12 and tm.sAnswer is not null
print @str