tags:

views:

23

answers:

2

Hi,

using a strored procedure i get a field like this

FileNo

0001 0002 0003

how to get this as 0001,0002,0003

pls help..

A: 

Is that what you mean?

declare @variable nvarchar(250)

select @variable = f1 + ',' + f2 + ',' f3 from table
Tzury Bar Yochay
not this way, if i have fieldsFileid | FileNum---------------1 00011 0002i want it asFileid | FileNum---------------1 0001,0002
pls consider Fileid,filenum as the fields of a table and the rest its values
I want to concatenate the row values based on a Field for eg(FileID)
+1  A: 

How about this:

select FileId, REPLACE(FileNum, ' ', ', ') from table
Noah Heldman
DECLARE @FullNames VARCHAR(100)SELECT @FullNames = ISNULL(@FullNames,'') + FileNum + ', ' FROM table
I did it using above code,thanks