SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Hit on DB from a User


Hit on DB from a User

Author
Message
VastSQL
VastSQL
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4375 Visits: 5157
Hi Experts,

We have a DB user names Supply . Application will hit the DB with this username.

Is there anyway to find the hit happening to the database?\



Thanks in Advance.
Lowell
Lowell
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27986 Visits: 39922
Ratheesh.K.Nair (12/5/2013)
Hi Experts,
We have a DB user names Supply . Application will hit the DB with this username.
Is there anyway to find the hit happening to the database?\
Thanks in Advance.

hit? not a SQL term, but here's some examples:

a connection can be found that has the username connecting via sp_who/sp_who2/sp_whoisactive or from a query like this:

select * from master.sys.dm_exec_sessions WHERE login_name = 'myDomain\lowell'




that's at the SERVER level, though;
at the database level, no one "logs in" or anything, but they might select/insert/update, so to track that you'd have to trace/audit etc to get info on who-did-what at the database level.

what exactly are you trying to do?

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Richard Fryar
Richard Fryar
SSC-Addicted
SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)

Group: General Forum Members
Points: 489 Visits: 1172
I've been asked before how many times a particular user has accessed objects in a database.

I solved it by creating a database audit specification to capture the SCHEMA_OBJECT_ACCESS_GROUP.

Here's the code I used

-- Setup the auditing
USE [master]
GO

CREATE SERVER AUDIT [User-Access]
TO FILE
( FILEPATH = N'F:\SQLdata\MSSQL10_50.A\MSSQL\Log' -- REPLACE WITH YOUR LOG PATH
,MAXSIZE = 0 MB
,MAX_ROLLOVER_FILES = 2147483647
,RESERVE_DISK_SPACE = OFF
)
WITH
( QUEUE_DELAY = 1000
,ON_FAILURE = CONTINUE
)
GO

ALTER SERVER AUDIT [User-Access] WITH (STATE = ON)
GO

USE [YOUR-DATABASE]
GO

CREATE DATABASE AUDIT SPECIFICATION [User-Access]
FOR SERVER AUDIT [User-Access]
ADD (SCHEMA_OBJECT_ACCESS_GROUP)
GO

ALTER DATABASE AUDIT SPECIFICATION [User-Access] WITH (STATE = ON)
GO

-- Let it run for a bit

-- Now stop the capture
USE [YOUR-DATABASE];
GO

ALTER DATABASE AUDIT SPECIFICATION [User-Access] WITH (STATE = OFF)

USE master;
GO

ALTER SERVER AUDIT [User-Access] WITH (STATE = OFF)
GO

-- Get the results
SELECT schema_name, object_name, server_principal_name, count(*)
FROM fn_get_audit_file('F:\SQLdata\MSSQL10_50.A\MSSQL\Log\User-Access*', default, default) -- REPLACE WITH YOUR LOG PATH
WHERE server_principal_name = 'THE-LOGIN-YOU-ARE-INTERESTED-IN'
AND schema_name NOT IN ('sys')
GROUP BY schema_name, object_name, server_principal_name
ORDER BY schema_name, object_name, server_principal_name
GO



Hope this helps.


Check Your SQL Servers Quickly and Easily
www.sqlcopilot.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search