Showing posts with label obtain. Show all posts
Showing posts with label obtain. Show all posts

Monday, March 26, 2012

How can I print a multi-value parameter

I have a multi-value parameter and I need to print its value in report.
But if I put in a text box =Parameters!Mine.Label when rendering I obtain #Error
How can I do it?
Thanks in advanceUse the .NET Framework function Join(). You can specify the delimiter as well.

Friday, March 23, 2012

How Can I obtain the Top 3 of a dataset

If I have say 20 records of sales employees, for example, how can I get the top 3 locations for $$$sales for EACH employee? Each employee can have multiple locations where they have sold(let's say up to 50). I only want the names of the top 3 locations. The closest I can get is filtering the dataset by a HAVING clause > a dollar amount but this still gives me between 3 - 12 records for each plus I have to literally enter each salesperson's number as it stands now. Is this a loop or a cursor? Thanks.

ddaveOnce you have your SQL set up to return the sales dollars for all of the locations, just add TOP 3 before the select:

SELECT TOP 3 Sum(Dollars) FROM MyTable;


Note that you can also SELECT TOP n PERCENT.|||General solution to your problem:

The TOP N clause in TSQL is useful, but is limited by the fact that it only applies to the entire recordset, and that it will not accept a variable as a parameter.

This method will return any requested number of records for each group of one or more column values in a dataset. It uses a type of join called a Theta join, where the values in two datasets are compared, but do not necessarily have to be equal:


declare @.N int
set @.N = 5 --The number of records to return for each grouping.
select YourTable.YourColumns
from YourTable
inner join YourTable ThetaTable
on YourTable.GroupColumns = ThetaTable.GroupColumns
and YourTable.SortColumn <= ThetaTable.SortColumn
group by YourTable.YourColumns
having count(*) <= @.N|||The TOP function does not work as blindman indicates as it gives me only the top 3 of 120+ records, not the top 3 for EACH person. I will try the Theta join. Thanks to both for replying.

ddave|||blindman, your queries are starting to look good :)

but the join should be outdented

use foo and bar if more than one column is intended (YourColumns alone does not show comma syntax)

and shorter aliases make it easier to read ;)select T.foo, T.bar
from YourTable as T
inner join YourTable as Th
on T.GroupColumns = Th.GroupColumns
and T.SortColumn <= Th.SortColumn
group by T.foo, T.bar
having count(*) <= n|||blindman, your queries are starting to look good :)

Looks can be deceiving...it doesn't work

USE Northwind
GO

SET NOCOUNT ON
CREATE TABLE myTable99(SiteId int, EmpId int, Sales money)
GO

INSERT INTO myTable99(SiteId, EmpId, Sales)
SELECT 1, 1, 10.00 UNION ALL
SELECT 2, 1, 15.00 UNION ALL
SELECT 3, 1, 20.00 UNION ALL
SELECT 4, 1, 50.00 UNION ALL
SELECT 5, 1, 10.00 UNION ALL
SELECT 6, 1, 5.00 UNION ALL
SELECT 1, 2, 100.00 UNION ALL
SELECT 2, 2, 1500.00 UNION ALL
SELECT 3, 2, 2000.00 UNION ALL
SELECT 4, 2, 5000.00 UNION ALL
SELECT 5, 2, 1000.00 UNION ALL
SELECT 6, 2, 500.00 UNION ALL
SELECT 1, 3, 1.00 UNION ALL
SELECT 2, 3, 1.50 UNION ALL
SELECT 3, 3, 2.00 UNION ALL
SELECT 4, 3, 5.00 UNION ALL
SELECT 5, 3, 1.00 UNION ALL
SELECT 6, 3, .50
GO

DECLARE @.N int
SET @.N = 3 --The number of records to return for each grouping.

SELECT a.SiteId, a.EmpId
FROM myTable99 a
JOIN myTable99 b
ON a.SiteId = b.SiteId
AND a.EmpId = b.EmpId
AND a.Sales < = b.Sales
GROUP BY a.SiteId, a.EmpId
HAVING COUNT(*) <= @.N
GO

SET NOCOUNT OFF
DROP TABLE myTable99
GO

I know I've seen this work somehow though|||At least to me, it is a lot more intuitively obvious to do this via a sub-query, something like: DECLARE @.N int
SET @.N = 3 --The number of records to return for each grouping.

SELECT a.SiteId, a.EmpId, a.Sales
FROM myTable99 a
WHERE (SELECT Count(*)
FROM myTable99 b
WHERE b.EmpId = a.EmpId
AND a.Sales <= b.Sales) <= @.N
ORDER BY a.EmpID, a.Sales DESC, a.SiteIDThe problem with any set-based solution to this kind of problem is that it does not deal well with "ties" in the data... They make your results a bit "funky", but I don't know any reliable way to resolve that using set based logic.

-PatP|||I know I've seen this work somehow thoughyeah, it's tricky

here's what you were searching for -- select a.EmpId
, a.SiteId
, a.sales
from myTable99 a
inner
join myTable99 b
on a.EmpId = b.EmpId
and a.Sales <= b.Sales
group
by a.EmpId
, a.SiteId
, a.sales
having count(*) <= 3
order
by a.EmpId
, a.sales descwhich produces the following (correct) results:1 4 50.0000
1 3 20.0000
1 2 15.0000

2 4 5000.0000
2 3 2000.0000
2 2 1500.0000

3 4 5.0000
3 3 2.0000
3 2 1.5000pat, i like the subquery method too, i guess i just got used to the join solution after so many times showing pre-4.1 mysql people how to do it

:) :)|||I indents 'em as I wants 'em, thank you! :)|||Hey thanks guys...

And yes Pat, I agree it may be more intuitive...but have a look at the plans...it looks like Rudy's Join is more effecient...even with the group by.

I would not have guessed this. Anyone care if I blog this? With appropriate references of course.

It's just one of things I know can be done...and I forget how to contruct it.

Anyway, here's the plans|||blog away

:cool: :cool: :cool:|||OK, You've all been Blogged (http://weblogs.sqlteam.com/brettk/archive/2005/02/10/4153.aspx)|||OK, You've all been Blogged (http://weblogs.sqlteam.com/brettk/archive/2005/02/10/4153.aspx)ta very much

and usually i just ignore your frequent typos, but in this case, i must insist that you correct the spelling of my surname

thanks in advance|||mia culpa...done|||mia culpa...donethanks

and now, would you mind changing the link so that it points to the correct person

:) :)|||Done...it's been a rough week...they've got me doing project plans...aaaahhhhhhhhh|||"The problem with any set-based solution to this kind of problem is that it does not deal well with "ties" in the data... They make your results a bit "funky", but I don't know any reliable way to resolve that using set based logic."

That is the catching point. I have 20 people, for each of whom I wish to get the "TOP 3" records. When I have a "tie" it fails, giving me only 2 of the 3 desired records.

I inserted a couple of extra records to the table given above by:

INSERT INTO myTable99(SiteId, EmpId, Sales)
SELECT 2, 2, 15.00
SELECT 2, 2, 1500.00

The 1500.00 will create a tie with another record, already having a value of 1500.00.

Here are all the records:

select *
from myTable99

Results:
1 1 10.0000
2 1 15.0000
3 1 20.0000
4 1 50.0000
5 1 10.0000
6 1 5.0000
1 2 100.0000
2 2 1500.0000
3 2 2000.0000
4 2 5000.0000
5 2 1000.0000
6 2 500.0000
1 3 1.0000
2 3 1.5000
3 3 2.0000
4 3 5.0000
5 3 1.0000
6 3 .5000
2 2 1500.0000
2 2 15.0000

When I run your query:

select a.EmpId
, a.SiteId
, a.sales
from myTable99 a
inner
join myTable99 b
on a.EmpId = b.EmpId
and a.Sales <= b.Sales
group
by a.EmpId
, a.SiteId
, a.sales
having count(*) <= 3
order
by a.EmpId
, a.sales desc

My results are here:

1 4 50.0000
1 3 20.0000
1 2 15.0000
2 4 5000.0000
2 3 2000.0000
3 4 5.0000
3 3 2.0000
3 2 1.5000

I need Employee 2 to show at least one of his two 1500.00 records. Any way to do this?

ddave|||This can still be done with a set-based solution:

select a.EmpId,
a.SiteId,
a.sales
from myTable99 a
inner join myTable99 b
on a.EmpId = b.EmpId
and (a.Sales < b.Sales
or a.Sales = b.Sales and a.EmpID < b.EmpID)
group by a.EmpId,
a.SiteId,
a.sales
having count(*) <= 3
order by a.EmpId,
a.sales desc

Output:

EmpId SiteId sales
---- ---- -------
1 3 20.0000
1 2 15.0000
1 1 10.0000
1 5 10.0000
2 3 2000.0000
2 2 1500.0000
2 5 1000.0000
3 3 2.0000
3 2 1.5000
3 1 1.0000
3 5 1.0000|||No kidding...

SELECT a.EmpId, a.SiteId, a.sales
FROM (SELECT DISTINCT EmpId, SiteId, sales FROM myTable99) a
INNER JOIN (SELECT DISTINCT EmpId, SiteId, sales FROM myTable99) b
ON a.EmpId = b.EmpId
AND a.Sales <= b.Sales
GROUP BY a.EmpId, a.SiteId, a.sales
HAVING COUNT(*) <= @.N
ORDER BY a.EmpId, a.sales desc
GO|||without getting into the actual sql, the problem of ties isn't really a problem of sql, it's more of a problem of semantics

blindman's last example is perfect --

3 3 2.0000
3 2 1.5000
3 1 1.0000
3 5 1.0000

as far as i'm concerned, a tie across the last place requires that all rows with that value be included

let's say we had 25 people in a classroom, and we wanted the top 3 students based on marks

joe has a gpa of 3.90, mary has a gpa of 3.85, and all twenty-three others have exactly the same gpa, 3.80

who ya gonna exclude?

How can I obtain the tine via Query Analyzer?

I know that that is a stupid thing but I can't remember it.
thanks thousandsIf you meant, time, then:
SELECT CURRENT_TIMESTAMP
or
SELECT GETDATE()
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:0B99C351-23F4-42CC-8B7B-F7B671B84569@.microsoft.com...
I know that that is a stupid thing but I can't remember it.
thanks thousands|||Cheers,
"Narayana Vyas Kondreddi" wrote:

> If you meant, time, then:
> SELECT CURRENT_TIMESTAMP
> or
> SELECT GETDATE()
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:0B99C351-23F4-42CC-8B7B-F7B671B84569@.microsoft.com...
> I know that that is a stupid thing but I can't remember it.
> thanks thousands
>
>|||Hi Enric
Vyas answered the question, but this is just an extension for the answer you
might be interested in it:
SELECT CONVERT(varchar(8),getdate(),108)
this will give you present time
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Enric" wrote:
> Cheers,
> "Narayana Vyas Kondreddi" wrote:
>

How can I obtain the SQl Server version?

How can I obtain the SQl Server version?select @.@.version
ML|||thanx
"ML" wrote:

> select @.@.version
>
> ML|||http://www.aspfaq.com/show.asp?id=2160
HTH, Jens Suessmeyer.
"Enric" wrote:

> regards,|||thanks a lot,
"Jens Sü?meyer" wrote:
> http://www.aspfaq.com/show.asp?id=2160
> HTH, Jens Suessmeyer.
> "Enric" wrote:
>|||Hello Enric,
see the SERVERPROPERTY function in Books online
Ο χρ?στη? "Enric" _γγραψε:

> regards,

Wednesday, March 21, 2012

How can I obtain the login name of the caller of my UDF written in a CLR language?

I am using MS SQL Server 2005.
Is there a way to obtain the login name of the caller of my user
defined function implement in managed C++?
I know I can get the information using the code segment below but I
want to avoid connecting back to the database for performance reasons.
String^ queryString = "select suser_sname()"
SqlConnection conn = gcnew SqlConnection(connectionString);
SqlCommand command = new SqlCommand(queryString, connection);
conn.Open();
SqlDataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnect ion);
while (reader.Read())
{
reader[0];
}
Thanks,
Steven
Examine using the Security object.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"smaully" <smauldin@.ingrian.com> wrote in message
news:1160176423.328986.327470@.i42g2000cwa.googlegr oups.com...
>I am using MS SQL Server 2005.
> Is there a way to obtain the login name of the caller of my user
> defined function implement in managed C++?
> I know I can get the information using the code segment below but I
> want to avoid connecting back to the database for performance reasons.
> String^ queryString = "select suser_sname()"
> SqlConnection conn = gcnew SqlConnection(connectionString);
> SqlCommand command = new SqlCommand(queryString, connection);
> conn.Open();
> SqlDataReader reader =
> command.ExecuteReader(CommandBehavior.CloseConnect ion);
> while (reader.Read())
> {
> reader[0];
> }
> Thanks,
> Steven
>
|||Darn Spell Checker.
Look into the SecurityPrinicipal object.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:uBNLaka6GHA.4620@.TK2MSFTNGP02.phx.gbl...
> Examine using the Security object.
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "smaully" <smauldin@.ingrian.com> wrote in message
> news:1160176423.328986.327470@.i42g2000cwa.googlegr oups.com...
>
|||Arnie,
That will return the Windows user not the sql login.
-Steve
|||I read that that is what you desired; "obtain the login name of the caller".
There was nothing to indicate you were using SQL Logins.
Since that is know to and in SQL Server, and not known to the client
application, the only way is to ask SQL Server to provide it. That may
require a 'wasted' round trip. You might call a stored procedure, have the
stored procedure call the UDF, and pass the SQL Login back as a output
parameter.
Of course, I don't know how you are using the UDF, so that may not work for
you.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"smaully" <smauldin@.ingrian.com> wrote in message
news:1160415121.924478.80610@.m7g2000cwm.googlegrou ps.com...
> Arnie,
> That will return the Windows user not the sql login.
> -Steve
>

How can I obtain the login name of the caller of my UDF written in a CLR language?

I am using MS SQL Server 2005.
Is there a way to obtain the login name of the caller of my user
defined function implement in managed C++?
I know I can get the information using the code segment below but I
want to avoid connecting back to the database for performance reasons.
String^ queryString = "select suser_sname()"
SqlConnection conn = gcnew SqlConnection(connectionString);
SqlCommand command = new SqlCommand(queryString, connection);
conn.Open();
SqlDataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
reader[0];
}
Thanks,
StevenExamine using the Security object.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"smaully" <smauldin@.ingrian.com> wrote in message
news:1160176423.328986.327470@.i42g2000cwa.googlegroups.com...
>I am using MS SQL Server 2005.
> Is there a way to obtain the login name of the caller of my user
> defined function implement in managed C++?
> I know I can get the information using the code segment below but I
> want to avoid connecting back to the database for performance reasons.
> String^ queryString = "select suser_sname()"
> SqlConnection conn = gcnew SqlConnection(connectionString);
> SqlCommand command = new SqlCommand(queryString, connection);
> conn.Open();
> SqlDataReader reader =
> command.ExecuteReader(CommandBehavior.CloseConnection);
> while (reader.Read())
> {
> reader[0];
> }
> Thanks,
> Steven
>|||Darn Spell Checker.
Look into the SecurityPrinicipal object.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:uBNLaka6GHA.4620@.TK2MSFTNGP02.phx.gbl...
> Examine using the Security object.
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "smaully" <smauldin@.ingrian.com> wrote in message
> news:1160176423.328986.327470@.i42g2000cwa.googlegroups.com...
>|||Arnie,
That will return the Windows user not the sql login.
-Steve|||I read that that is what you desired; "obtain the login name of the caller".
There was nothing to indicate you were using SQL Logins.
Since that is know to and in SQL Server, and not known to the client
application, the only way is to ask SQL Server to provide it. That may
require a 'wasted' round trip. You might call a stored procedure, have the
stored procedure call the UDF, and pass the SQL Login back as a output
parameter.
Of course, I don't know how you are using the UDF, so that may not work for
you.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"smaully" <smauldin@.ingrian.com> wrote in message
news:1160415121.924478.80610@.m7g2000cwm.googlegroups.com...
> Arnie,
> That will return the Windows user not the sql login.
> -Steve
>

How can I obtain the login name of the caller of my UDF written in a CLR language?

I am using MS SQL Server 2005.
Is there a way to obtain the login name of the caller of my user
defined function implement in managed C++?
I know I can get the information using the code segment below but I
want to avoid connecting back to the database for performance reasons.
String^ queryString = "select suser_sname()"
SqlConnection conn = gcnew SqlConnection(connectionString);
SqlCommand command = new SqlCommand(queryString, connection);
conn.Open();
SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
reader[0];
}
Thanks,
StevenExamine using the Security object.
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"smaully" <smauldin@.ingrian.com> wrote in message
news:1160176423.328986.327470@.i42g2000cwa.googlegroups.com...
>I am using MS SQL Server 2005.
> Is there a way to obtain the login name of the caller of my user
> defined function implement in managed C++?
> I know I can get the information using the code segment below but I
> want to avoid connecting back to the database for performance reasons.
> String^ queryString = "select suser_sname()"
> SqlConnection conn = gcnew SqlConnection(connectionString);
> SqlCommand command = new SqlCommand(queryString, connection);
> conn.Open();
> SqlDataReader reader => command.ExecuteReader(CommandBehavior.CloseConnection);
> while (reader.Read())
> {
> reader[0];
> }
> Thanks,
> Steven
>|||Darn Spell Checker.
Look into the SecurityPrinicipal object.
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:uBNLaka6GHA.4620@.TK2MSFTNGP02.phx.gbl...
> Examine using the Security object.
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "smaully" <smauldin@.ingrian.com> wrote in message
> news:1160176423.328986.327470@.i42g2000cwa.googlegroups.com...
>>I am using MS SQL Server 2005.
>> Is there a way to obtain the login name of the caller of my user
>> defined function implement in managed C++?
>> I know I can get the information using the code segment below but I
>> want to avoid connecting back to the database for performance reasons.
>> String^ queryString = "select suser_sname()"
>> SqlConnection conn = gcnew SqlConnection(connectionString);
>> SqlCommand command = new SqlCommand(queryString, connection);
>> conn.Open();
>> SqlDataReader reader =>> command.ExecuteReader(CommandBehavior.CloseConnection);
>> while (reader.Read())
>> {
>> reader[0];
>> }
>> Thanks,
>> Steven
>|||Arnie,
That will return the Windows user not the sql login.
-Steve|||I read that that is what you desired; "obtain the login name of the caller".
There was nothing to indicate you were using SQL Logins.
Since that is know to and in SQL Server, and not known to the client
application, the only way is to ask SQL Server to provide it. That may
require a 'wasted' round trip. You might call a stored procedure, have the
stored procedure call the UDF, and pass the SQL Login back as a output
parameter.
Of course, I don't know how you are using the UDF, so that may not work for
you.
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"smaully" <smauldin@.ingrian.com> wrote in message
news:1160415121.924478.80610@.m7g2000cwm.googlegroups.com...
> Arnie,
> That will return the Windows user not the sql login.
> -Steve
>

how can I obtain message_id?

Hi all!

How can I obtain message_id when I SEND the message, before I execute RECEIVE statement?

Thanks a lot for the help!

Are you sending to a service and then wanting to recieve from it straight after in the same code?
What are you trying to achieve with this code?

|||

Hi, SimonS_! Thank you for fast response.

I'm send the message in one procedure:

create procedure [dbo].[proc_Client]

as

begin

set nocount on;

declare @.conversation_handle uniqueidentifier

begin dialog conversation @.conversation_handle

FROM SERVICE [My Service1]

TO SERVICE [My Service2]

ON CONTRACT [Custom Comtract]

send on conversation @.conversation_handle message type [//Messaging/CustomMsg]('message data');

and here I want to save the Service Broker message_ID in the my table

end conversation @.conversation_handle;

end

Then I have an Activation Procedure:

CREATE Procedure [proc_ms_Activation]

AS

BEGIN

SET NOCOUNT ON

WAITFOR (RECEIVE TOP(1) @.internal_SB_message_id = message_id, @.message_type_name = message_type_name, @.message_body = message_body, @.conversation_handle = conversation_handle FROM Queue1);

END

mesage_id I receive only in [proc_ms_Activation], but I need save this message_id in [proc_Client] procedure. Could you please help me?

|||

I still don't know why you need the message Id.

Are you trying to manage state ?

|||Yes, I'm try to manage message state, keep messages in database and found it, and I have additional logic - gathering statistics, track poison messages and etc|||

Two points,

Messages that come back to your initiator service use the same conversation group. This means that if you specify a conversation group you can use that to correlate messages you send to messages you receive.

In this situation generate a guid (newid()) and then use that for the conversation_group_id. Then you can store it in a table, If you want the target service to know this id then you will need to include it in the message.

|||

We didn't see a need to expose message_ids at the system level since apps that require tracking state at a per-message level would have primitives within the app itself for doing so. You could for example stick some cookie into the message sent by the initiator and relay it back with the response so that your app can corelate the response to the request. Depending on the app this may be a 'request ID', an 'order number', a 'service request ticket', etc.

Rushi

|||

The other way to refactor the app would be to think of a conversation as being the primitive for identifying a request. So each request would be sent on its own unique conversation. That way the app can store state with the conversation itself (and you could use conversation_handle or conversation_group_id* as the primary key in that case). Responses for a particular request would only come back on the same conversation and hence you can easily correlate them. In fact we provide locking at the conversation level to prevent multiple queue readers from accessing the same conversation at the same time.

Rushi

*: You WILL need to use conversation_groups if you want to relate multiple conversations together. Even if today you don't do that, conversation_group_id is a better way to key state than handles.

|||

Rushi, thanks a lot for the detailed explanation.

The best decision for me will use one-message-per-dialog conversation and send one message per conversation, then trace application logic on conversation_id.

Thank you,

Sveta.

|||You don't have to have one message per dialog for this to work. I would say you want 1 Dialog per business transaction, that way any responses to any messages are on the same conversation group. You might want to send two messages rather than having to combine data from different sources in one message

How can I obtain all the SQL SERVER's names in my domain

Dear all,
Regarding the aforementioned question I don't know if launching one script
in VB
and retrieving all the names is compulsory.
Is there any way or method for obtain that info via job/sp?
I hope have been sufficiently explicit.
Thanks in advance and regards,Hi,
Try the below command from command prompt.
OSQL -L
Thanks
Hari
SQL Server MVP
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:85E1BA68-3430-4807-BCC0-FD77AB8698A9@.microsoft.com...
> Dear all,
> Regarding the aforementioned question I don't know if launching one script
> in VB
> and retrieving all the names is compulsory.
> Is there any way or method for obtain that info via job/sp?
> I hope have been sufficiently explicit.
> Thanks in advance and regards,|||thanks a lot Hari
"Hari Prasad" wrote:

> Hi,
> Try the below command from command prompt.
> OSQL -L
> Thanks
> Hari
> SQL Server MVP
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:85E1BA68-3430-4807-BCC0-FD77AB8698A9@.microsoft.com...
>
>sql

How can I obtain a report of users and roles in SQL Server?

I need a query (script) or a tool to obtain a report (or audit report) for
all databases instanced into SQL Server, just for an entittlement review aun
audit reports.
The fields are:
User, role, permissions, last date access
Best regards to everyone.
JosSee:-
SYSPROTECT system table and system procedure SP_HELPROTECT
Thanks
Hari
SQL Server MVP
"Jos Archondo" <jarchondo@.spvs.gov.bo> wrote in message
news:uMv%23UlC1FHA.664@.tk2msftngp13.phx.gbl...
>I need a query (script) or a tool to obtain a report (or audit report) for
> all databases instanced into SQL Server, just for an entittlement review
> aun
> audit reports.
> The fields are:
> User, role, permissions, last date access
> Best regards to everyone.
> Jos
>|||You should also run sp_helplogins. That will help define where
sp_helprotect should be run.
RLF
"Jos Archondo" <jarchondo@.spvs.gov.bo> wrote in message
news:uMv%23UlC1FHA.664@.tk2msftngp13.phx.gbl...
>I need a query (script) or a tool to obtain a report (or audit report) for
> all databases instanced into SQL Server, just for an entittlement review
> aun
> audit reports.
> The fields are:
> User, role, permissions, last date access
> Best regards to everyone.
> Jos
>