Concatenation of integers with commas in SQL Server? -


i find execute following query:

select * table id in (1,2,3,4) 

is there function can concatenate resultset returns integers commas?

for example

concatenate(select id table) return 1,2,3,4

this trick... think more efficient in application layer there times (reporting) when end resorting these types of tricks.

declare @liststr varchar(max) select @liststr = coalesce(@liststr+',' ,'') + cast(id varchar(10)) table select @liststr 

i learned trick pinal dave see: create comma delimited list using select clause table column


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -