bikerboy718
Programmer
I was wondering if anyone know how I can concatenate a column in SQL Server. I a comments field that I have to include in an email for all comments that were made for a particular order. This is what i have so far:
This is what I tried but I get a null value for the variable @msg. Any help is greatly appreciated.
With Great Power Comes Great Responsibility!!!![[afro] [afro] [afro]](/data/assets/smilies/afro.gif)
Michael
Code:
declare @msg nvarchar(4000), @temp nvarchar(400)
declare @RowCnt int, @RC INT, @MaxRows int
declare @TBL_remarks table (rownum int IDENTITY (1, 1) Primary key NOT NULL
,remarks nvarchar(800))
insert @TBL_remarks
select remarks from orderitemhold
where orderitemid = 5770420
select @RowCnt = 1
select @maxRows = count(*) from @TBL_Remarks
while @rowCnt <= @maxRows
begin
Select @temp = Remarks from @TBL_remarks where rownum = @rowCnt
select @msg = @msg + @temp
Select @RowCnt = @RowCnt + 1
end
select @msg
This is what I tried but I get a null value for the variable @msg. Any help is greatly appreciated.
With Great Power Comes Great Responsibility!!!
![[afro] [afro] [afro]](/data/assets/smilies/afro.gif)
Michael