Monday, March 19, 2012

Getting records in a line (commalist)

Hi,

i searched for many hours now and I need help from the community ;)

I have a list of records and want to include the records as a comma sperated list in an other select statement.

I tried it with std. SQL and later with T-SQL, and I am sure it will work ith a stored procedure, but I am not that professional in this (try to learn...).

Background: I have a lot of data (users) and want to create a records set without having the data processed in my scripts.

So i have: records in table krgroupusers (example data):

lgroupid, luserid
3 , 1
3 , 48
4 , 1
197 , 1
197 , 48
197 , 250
197 , 251
207 , 1

207 , 250

Weiter habe ich eine Tabelle kruser (example data):

lid, strusername , strmail
1 , Administrator , admin@.test.de
48 , user1 , user1@.test.de
250, user2 , user2@.test.de
251, user3 , user3@.test.de

A StoredP. or SQL query should give me the following result:

lid, strusername , strmail , sgroups (example data):

1 , Administrator , admin@.test.de , 3,4,197,207
48 , user1 , user1@.test.de , 3,197
250, user2 , user2@.test.de , 197,207
251, user3 , user3@.test.de , 197

So I am happy for any help...

hi Yves,

please refer to this post

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=586833&SiteID=1

regards

|||

Hi,

Thx alot that helps me to do it.

One final question ;) Is it possible to do this with a virtual table ?! or do i have to create a table and drop it again.

I not familiar with this but i read some things about @.@.table...

No comments:

Post a Comment