Unix Technical Forum

Extract "GroupName" from "sp_helpuser"

This is a discussion on Extract "GroupName" from "sp_helpuser" within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi all, I want to create a stored procedure which will extract the "GroupName" from the record returned by ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:12 PM
Alvin Sebastian
 
Posts: n/a
Default Extract "GroupName" from "sp_helpuser"

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,

Alvin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 05:12 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Extract "GroupName" from "sp_helpuser"

Alvin Sebastian (asebastian@cmri.usyd.edu.au) writes:
> 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?


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
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 05:12 PM
Alvin Sebastian
 
Posts: n/a
Default Re: Extract "GroupName" from "sp_helpuser"

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




Erland Sommarskog <sommar@algonet.se> wrote in message news:<Xns93BF646E19EF7Yazorman@127.0.0.1>...
> Alvin Sebastian (asebastian@cmri.usyd.edu.au) writes:
> > 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?

>
> 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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 05:12 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Extract "GroupName" from "sp_helpuser"

Alvin Sebastian (asebastian@cmri.usyd.edu.au) writes:
> 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"?


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
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 05:13 PM
Alvin Sebastian
 
Posts: n/a
Default Re: Extract "GroupName" from "sp_helpuser"

Thanks Erland, I got it working now!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com