Groups | Blog | Home
all groups > sql server mseq > november 2006 >

sql server mseq : SQL Query Help


Hotmail
11/16/2006 4:05:02 AM
I am a bit of a newbie to SQL Queries and need some help with the following
query.

I have two tables in SQL 2000 which hold info about user and roles.

In the first table I have a set of user info containing the user name and
its email address. the user name is the primary key in this table.

In the second table I have a set of role information which contains the role
name, role email address and a reference to the user who holds that role. The
user can be a member of many roles so he can be referenced in the roles table
maultiple times.

What I want is to output is an ammalgameted view of this data keyed on the
user name as follows:-

user1, user1 email address, role1 email address, role2 email address ...
user2, user2 email address, role3 email address, role4 email address...

I created a basic select qury between the two tables but it only produced
the records on a separate row each. How can I get the multiple roles to link
to the user in a single row?

Thanks
Hotmail
Arnie Rowland
11/19/2006 3:07:02 PM
I believe that one of these resources will point you in a direction that
will work for you:

Lists -Field Concatenation
http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/2d85bf366dd9e73e

Lists -Field Concatenation ( For SQL 2000 & 2005 )
http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/7e5b4c8a9b9b968a

Lists -Field Concatenation, One Field to Itself for string
SQL 2000
http://omnibuzz-sql.blogspot.com/2006/06/concatenate-values-in-column-in-sql.html
SQL 2005
http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/07/06/871.aspx
http://www.projectdmx.com/tsql/rowconcatenate.aspx


--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


[quoted text, click to view]

AddThis Social Bookmark Button