Groups | Blog | Home
all groups > sql server (alternate) > july 2003 >

sql server (alternate) : Extract "GroupName" from "sp_helpuser"


asebastian NO[at]SPAM cmri.usyd.edu.au
7/20/2003 10:24:08 PM
Hi all,

I want to create a stored procedure which will extract the "GroupName"
from the record returned by "sp_helpuser". In order to do this I need
to execute "sp_helpuser" which returns the entire record. I want to
just extract the "GroupName" from the record and return it to my
application. How do I go about this?

Thanks in advance,

Erland Sommarskog
7/21/2003 7:53:34 AM
Alvin Sebastian (asebastian@cmri.usyd.edu.au) writes:
[quoted text, click to view]

Either you access sysusers directly, you can use the INSERT EXEC construct:

INSERT #temp (...)
EXEC sp_helpuser

You need to create #temp so that it agrees with the output from sp_helpuser.


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
asebastian NO[at]SPAM cmri.usyd.edu.au
7/21/2003 7:23:13 PM
Thanks Erland.

By the way, I forgot to mention in the first post that I'm only
interested in the "GroupName" of the currently logged-on user so the
stored procedure will be returning a single string value only and not
a table. How should the stored procedure return this single value from
the record returned by "sp_helpuser"?


Alvin




[quoted text, click to view]
Erland Sommarskog
7/22/2003 7:41:29 AM
Alvin Sebastian (asebastian@cmri.usyd.edu.au) writes:
[quoted text, click to view]

A one-row result set is still a table.

There is the OPENQUERY method as well.

See http://www.algonet.se/~sommar/share_data.html where I discuss both
methods.

--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
asebastian NO[at]SPAM cmri.usyd.edu.au
7/22/2003 10:29:28 PM
AddThis Social Bookmark Button