473,804 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Seperating the results of sp_dbfixedrolep ermission by fixedbroles

I will like to seperate the contents of sp_dbfixedrolep ermission
into groups by the fixedrole (With the LUXURY of a heading).Is there
a any short way or straight forward command to do that?

TIA

TY
Jul 20 '05 #1
5 1778
[posted and mailed, please reply in news]

Tyler Smith Watu (wa********@yah oo.co.nz) writes:
I will like to seperate the contents of sp_dbfixedrolep ermission
into groups by the fixedrole (With the LUXURY of a heading).Is there
a any short way or straight forward command to do that?


Normally you would use a reporting tool for things like adding headers.
But assuming that you want to run this from Query Analyzer, yes there
is a way, but straightforward ? Nah...

Here is the beast:

SELECT * FROM
(SELECT * FROM
OPENQUERY (LOOPBACK,
'SET FMTONLY OFF EXEC tempdb..sp_dbfi xedrolepermissi on'))
AS h (DbFixedRole, Permission)
ORDER BY DbFixedRole
COMPUTE COUNT(Permissio n) BY DbFixedRole

The non-relational COMPUTE is the one way there is to get a header
for each group in a header. An alternative though, would be to get
data into temp table with a third column, which is char(13) + char(10)
for the last row in each group.

To run a system stored procedure in a SELECT statement I use OPENQUERY.
LOOPBACK is a linked server that points back to the local server. The
SET FMTONLY OFF was necessary, because apparently sp_dbfixedrolep ermission
uses temp tables. The FMTONLY OFF fools OPENQUERY, but the procedure
is actually ran twice. While this method can be used to run about any
stored procedure from a SELECT statement, it should be used with caution.
See http://www.sommarskog.se/share_data.html#OPENQUERY for more details.

I also needed a derived table, so I could specify the column names.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Before I get some dust off my books did you say there was an
alternative way?
This may be asking too much but If you do not mind could you elaborate
a little on the alternative way?

Thank you very much for your time

TY
Jul 20 '05 #3
Tyler Smith Watu (wa********@yah oo.co.nz) writes:
Before I get some dust off my books did you say there was an
alternative way?
This may be asking too much but If you do not mind could you elaborate
a little on the alternative way?


It's even uglier:

SELECT *, last = ' '
INTO #tmp
FROM
(SELECT * FROM
OPENQUERY (KESÄMETSÄ,
'SET FMTONLY OFF EXEC tempdb..sp_dbfi xedrolepermissi on'))
AS h (DbFixedRole, Permission)
ORDER BY DbFixedRole, Permission

UPDATE #tmp
SET last = char(10)
FROM #tmp t
JOIN (SELECT DbFixedRole, perm = MAX(Permission)
FROM #tmp
GROUP BY DbFixedRole) u
ON t.DbFixedRole = u.DbFixedRole
AND t.Permission = u.perm

SELECT * FROM #tmp ORDER BY DbFixedRole, Permission
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4
Erland Sommarskog <es****@sommars kog.se> wrote in message news:<Xn******* *************** @127.0.0.1>...
Tyler Smith Watu (wa********@yah oo.co.nz) writes:
Before I get some dust off my books did you say there was an
alternative way?
This may be asking too much but If you do not mind could you elaborate
a little on the alternative way?


It's even uglier:

SELECT *, last = ' '
INTO #tmp
FROM
(SELECT * FROM
OPENQUERY (KESÄMETSÄ,
'SET FMTONLY OFF EXEC tempdb..sp_dbfi xedrolepermissi on'))
AS h (DbFixedRole, Permission)
ORDER BY DbFixedRole, Permission

UPDATE #tmp
SET last = char(10)
FROM #tmp t
JOIN (SELECT DbFixedRole, perm = MAX(Permission)
FROM #tmp
GROUP BY DbFixedRole) u
ON t.DbFixedRole = u.DbFixedRole
AND t.Permission = u.perm

SELECT * FROM #tmp ORDER BY DbFixedRole, Permission


Thanks for the opportunity to learn something new.

After setting up a linked server and running the transact sql provided
the results are about identical to what I had

1)I created two tables and inserted the values of
sp_dbfixedrolep ermission
on one and sp_helpsrvrolem ember on the other .
2)The second table had an identity column which was used to ensure I
could get the roles for each fixeddbrole as needed.
3)The two tables where then joined using a stored procedure which
produced the required results.

Now the not so necessary question is

Is there some configuration to clear the tabs in the resultset?i.e So
that it is possible to cut and paste ALL the resultset in notepad
(not piecemeal)

Thanks

TY
Jul 20 '05 #5
Tyler Smith Watu (wa********@yah oo.co.nz) writes:
Is there some configuration to clear the tabs in the resultset?i.e So
that it is possible to cut and paste ALL the resultset in notepad
(not piecemeal)


I'm not sure what you mean here. The result set itself does not include
any formatting. If you run from text mode in Query Analyzer, all you
will get is spaces. Many spaces that's true, and maybe too many spaces.

But you could get the data into a temp table, and the use dynamic SQL to
select a result set where the column widths are adapted to the largest
rows.

Rather than giving an example on how to do it, I refer you to the source
code of the system stored procedure sp_who2 that employs this technique.
Press F8 to get an object browser, and then drill down to it in the master
database.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1271
by: flupke | last post by:
Hi, i need to develop an app here which will be used to produce stats. I'm going to go with twisted pb for the client server communication. And wxPython for the GUI. Now i would want to split the GUI code from the pb code to make debugging easier amongst other things but i'm not sure how i would best implement the communication of between the GUI and the client. Do i also use pb for it? But then i would end up with the problems that
2
3539
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned from my search and how many records I have set it to display per page. All great so far, HOWEVER..... When you click the next link to see the next 10 results on the next page, it just dumps the search details and pulls up all the records in the...
6
1951
by: Jo K. | last post by:
I have a bounded field called Name. It's used to type in the full name of a customer (intentionally set up that way instead of seperating the first and last names) I would like to be able to seperate the names in say a report. When merging data from the database to a word document, I would like the database to insert the first name for the "Dear" part of the letter. eg. James Smith is the full entry in the field. The report would...
0
984
by: AnkitAsDeveloper [Ankit] | last post by:
As all we know, in order to remove cyclic includes in C++ we seperate the declarations and definitions of classs and it's member in two files Header (*.h) and source files (*.cpp). This is not a problem for C# as there is no concept of include. I faced problems for seperating declarations and definitions for class when it contains properties. This can also be done in context of struct/structures. Here is how we can. Class A
1
3548
by: Don | last post by:
I am new to Indexing Services, have been researching the MS Site as well as web articles on DevHood, etc. I have set up a seperate catalog ("KnowledgeBase") on Win XP with a number of files. I am trying to use OLEDB through ADO to search results and serve them up onto an ASP.Net web page, yet I consistently get back 0 results. I have this working fine in a console application. I think my problem is I have to allow IIS access to my IS...
0
1907
by: Rob | last post by:
I doubt this is the best way to do it, but what I came up with was to hide the XML in an HTML Comment then edit the file deleting the HTML stuff and keep the XML results. If anyone has a better solution, I would be interested. Thank you. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cmd As System.Data.SqlClient.SqlCommand cmd = New System.Data.SqlClient.SqlCommand
4
1642
by: jaYPee | last post by:
I have downloaded some source code but I want this to convert the results into datagrid. dr = cmd.ExecuteReader() '**************************************** ' SHOW THE RESULTS '**************************************** sResults = "CustomerID" + vbTab + "ContactName" + vbTab +
1
1293
by: oaklander | last post by:
Is it okay to keep creating queries with the same ResultSet Object reference (results)? Here is what I am currently using in my Database statements with Oracle and everything works but was wondering if this is okay where I am using ResultSet results for 3 queries in my Tomcat container: ResultSet results = null; Statement statement = null; ...... statement = connection.createStatement(); results =...
3
1508
by: Bigalan | last post by:
Hello, i am relatively new to PHP and i am struggling with printing multiple search results on to different pages. The code below works ok but when you click on next page button, it brings up a blank screen. I think it might have something to do with resetting the $found variable. Can you have a quick look? any suggestions would be greatly appreciated. <? if ($_GET) $vars=$_GET; else $vars=$_POST; $found = $vars;
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.