Transact SQL :: Log What Users Accessed Which Databases

Nov 9, 2015

I'd like to find out who is accessing various databases and log the time they did so.

Is there a way to do this? I just need the account name and the time logged and then to write to a table so I can query it.

View 2 Replies


ADVERTISEMENT

Transact SQL :: Fine Tune Procedure / Accessed By Multiple Users

Oct 13, 2015

i have a report that runs on a huge table rpt.AgentMeasures  , it has 10 months worth of data (150 million records as of today and will keep increasing).  i have pasted my proc below , the other tables that are joined to this huge table do not have more then 3k records.This report will be accessed by multiple users (expecting 20 ppl). as of now this reports runs for 5 mins if i pull for 1 month worth of data. if it is wise to use temp tables.

ALTER proc [rpt].[Get_Metrics]
@MinDate DATETIME,
@MaxDate DATETIME,
@Medium Varchar(max),
@footPrint varchar(max),

[code]...

View 10 Replies View Related

Transact SQL :: Script To Disconnect All Users Except One From Two Databases

Aug 20, 2015

I need a script to kill existing sessions on [db1] and [db2] except sessions from [user1]. I have a script like this now:

USE master
GO
DECLARE @kill varchar(8000) = '';
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), spid) + ';'
FROM master..sysprocesses
WHERE dbid = db_id('db1)
EXEC(@kill);

I just need to extend to run on db2 and don't kill sessions from user1

View 3 Replies View Related

Script To Log/record The Users Who Accessed My Database

Jul 10, 2006

Hi,

I am hosting my database on a third-party Microsoft SQL server. The guest user is "Off". But, I am not sure if any one else is accessing/viewing/editing my database contents.

Can I know/log/record the users/logins who are viewing/accessing my database. Is there any script or any exisitng machnism which can be used to track these users.

Also, are there any things that I should take care with my database from outside users.


Thanks
-Sudhakar

View 2 Replies View Related

Script To Log/record The Users Who Accessed My Database

Jul 10, 2006

Hi,

I am hosting my database on a third-party Microsoft SQL server. The guest user is "Off". But, I am not sure if any one else is accessing/viewing/editing my database contents.

Can I know/log/record the users/logins who are viewing/accessing my database. Is there any script or any exisitng machnism which can be used to track these users.

Also, are there any things that I should take care with my database from outside users.


Thanks
-Sudhakar

View 1 Replies View Related

Script To Log/record The Users Who Accessed My Database

Jul 10, 2006

Hi,I am hosting my database on a third-party Microsoft SQL server. The guest user is "Off". But, I am not sure if any one else is accessing/viewing/editing my database contents. Can I know/log/record the users/logins who are viewing/accessing my database. Is there any script or any exisitng machnism which can be used to track these users.Also, are there any things that I should take care with my database from outside users.Thanks-Sudhakar

View 1 Replies View Related

SQL Server Admin 2014 :: List Of Users That Accessed A Table

Jul 22, 2015

I'm trying to find out what tables are being used in a Database.

I don't want the last User but the User and the Dates.

I have a script that return the last user but that is not going to work.

The following script returns the last user but not all users and the Login Name:

ITH LastActivity (ObjectID, LastAction) AS
(
SELECT object_id AS TableName,
last_user_seek as LastAction
FROM sys.dm_db_index_usage_stats u
WHERE database_id = db_id(db_name())

[Code] .....

View 2 Replies View Related

What Is The Solution For This Internal Error EnsureMyReportsExists: Users Folder Not Found When My Reports Accessed

Nov 1, 2007

Any help would be apprecaited....

aspnet_wp!library!1!11/01/2007-09:36:59:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., EnsureMyReportsExists: Users folder not found when My Reports accessed.;
Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details.
aspnet_wp!library!1!11/01/2007-09:37:04:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson
aspnet_wp!webserver!1!11/01/2007-09:37:04:: e ERROR: Reporting Services error Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details.


10/31/07 14:54:06, ERROR , SQLDUMPER_UNKNOWN_APP.EXE, AdjustTokenPrivileges () failed (00000514)
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Input parameters: 4 supplied
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ProcessID = 2160
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ThreadId = 0
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Flags = 0x0
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDumpFlags = 0x0
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, SqlInfoPtr = 0x053F5860
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, DumpDir = <NULL>
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExceptionRecordPtr = 0x00000000
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ContextPtr = 0x00000000
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExtraFile = <NULL>
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, InstanceName = <NULL>
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ServiceName = <NULL>
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 11 not used
10/31/07 14:54:06, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 15 not used
10/31/07 14:54:10, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 7 not used
10/31/07 14:54:10, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDump completed: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFilesSQLDmpr0001.mdmp
10/31/07 14:54:10, ACTION, aspnet_wp.exe, Watson Invoke: No
10/31/07 15:25:56, ERROR , SQLDUMPER_UNKNOWN_APP.EXE, AdjustTokenPrivileges () failed (00000514)
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Input parameters: 4 supplied
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ProcessID = 2160
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ThreadId = 0
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Flags = 0x0
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDumpFlags = 0x0
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, SqlInfoPtr = 0x07E31E9C
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, DumpDir = <NULL>
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExceptionRecordPtr = 0x00000000
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ContextPtr = 0x00000000
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExtraFile = <NULL>
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, InstanceName = <NULL>
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ServiceName = <NULL>
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 11 not used
10/31/07 15:25:56, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 15 not used
10/31/07 15:25:59, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 7 not used
10/31/07 15:25:59, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDump completed: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFilesSQLDmpr0002.mdmp
10/31/07 15:25:59, ACTION, aspnet_wp.exe, Watson Invoke: No
10/31/07 15:28:01, ERROR , SQLDUMPER_UNKNOWN_APP.EXE, AdjustTokenPrivileges () failed (00000514)
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Input parameters: 4 supplied
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ProcessID = 2160
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ThreadId = 0
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Flags = 0x0
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDumpFlags = 0x0
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, SqlInfoPtr = 0x07E32A04
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, DumpDir = <NULL>
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExceptionRecordPtr = 0x00000000
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ContextPtr = 0x00000000
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExtraFile = <NULL>
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, InstanceName = <NULL>
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ServiceName = <NULL>
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 11 not used
10/31/07 15:28:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 15 not used
10/31/07 15:28:04, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 7 not used
10/31/07 15:28:04, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDump completed: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFilesSQLDmpr0003.mdmp
10/31/07 15:28:04, ACTION, aspnet_wp.exe, Watson Invoke: No
10/31/07 15:29:31, ERROR , SQLDUMPER_UNKNOWN_APP.EXE, AdjustTokenPrivileges () failed (00000514)
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Input parameters: 4 supplied
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ProcessID = 2160
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ThreadId = 0
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Flags = 0x0
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDumpFlags = 0x0
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, SqlInfoPtr = 0x07E3356C
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, DumpDir = <NULL>
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExceptionRecordPtr = 0x00000000
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ContextPtr = 0x00000000
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExtraFile = <NULL>
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, InstanceName = <NULL>
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ServiceName = <NULL>
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 11 not used
10/31/07 15:29:31, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 15 not used
10/31/07 15:29:34, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 7 not used
10/31/07 15:29:34, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDump completed: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFilesSQLDmpr0004.mdmp
10/31/07 15:29:34, ACTION, aspnet_wp.exe, Watson Invoke: No
10/31/07 15:31:14, ERROR , SQLDUMPER_UNKNOWN_APP.EXE, AdjustTokenPrivileges () failed (00000514)
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Input parameters: 4 supplied
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ProcessID = 2160
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ThreadId = 0
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Flags = 0x0
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDumpFlags = 0x0
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, SqlInfoPtr = 0x07E340D4
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, DumpDir = <NULL>
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExceptionRecordPtr = 0x00000000
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ContextPtr = 0x00000000
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExtraFile = <NULL>
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, InstanceName = <NULL>
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ServiceName = <NULL>
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 11 not used
10/31/07 15:31:14, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 15 not used
10/31/07 15:31:17, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 7 not used
10/31/07 15:31:17, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDump completed: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFilesSQLDmpr0005.mdmp
10/31/07 15:31:17, ACTION, aspnet_wp.exe, Watson Invoke: No
10/31/07 15:37:52, ERROR , SQLDUMPER_UNKNOWN_APP.EXE, AdjustTokenPrivileges () failed (00000514)
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Input parameters: 4 supplied
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ProcessID = 2160
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ThreadId = 0
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Flags = 0x0
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDumpFlags = 0x0
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, SqlInfoPtr = 0x07E34C3C
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, DumpDir = <NULL>
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExceptionRecordPtr = 0x00000000
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ContextPtr = 0x00000000
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExtraFile = <NULL>
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, InstanceName = <NULL>
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ServiceName = <NULL>
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 11 not used
10/31/07 15:37:52, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 15 not used
10/31/07 15:37:54, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 7 not used
10/31/07 15:37:54, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDump completed: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFilesSQLDmpr0006.mdmp
10/31/07 15:37:54, ACTION, aspnet_wp.exe, Watson Invoke: No
11/01/07 09:37:01, ERROR , SQLDUMPER_UNKNOWN_APP.EXE, AdjustTokenPrivileges () failed (00000514)
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Input parameters: 4 supplied
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ProcessID = 260
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ThreadId = 0
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Flags = 0x0
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDumpFlags = 0x0
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, SqlInfoPtr = 0x47405860
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, DumpDir = <NULL>
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExceptionRecordPtr = 0x00000000
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ContextPtr = 0x00000000
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ExtraFile = <NULL>
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, InstanceName = <NULL>
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, ServiceName = <NULL>
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 11 not used
11/01/07 09:37:01, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 15 not used
11/01/07 09:37:04, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, Callback type 7 not used
11/01/07 09:37:04, ACTION, SQLDUMPER_UNKNOWN_APP.EXE, MiniDump completed: C:Program FilesMicrosoft SQL ServerMSSQL.4Reporting ServicesLogFilesSQLDmpr0007.mdmp
11/01/07 09:37:04, ACTION, aspnet_wp.exe, Watson Invoke: No

View 6 Replies View Related

SQL Server Admin 2014 :: List All Databases In Instance That Are Not Accessed Before Given Date

Jan 10, 2015

Looking for query that lists all databases, in an instance, that are not accessed before a given date (e.g., not accessed before December 31, 2014)?

View 6 Replies View Related

Users And Logins Across Databases

Jun 2, 2007

hi,

In sql2k you used to be able to have a same user in 2 databases under the same login. Just moved to 2005, using sql authentication, and have some users who need to access 2 databases using the same login credentials. But sql2005 will not let me create 2 users under the same login across databases. Any ideas?

Thanks,
Mat

View 1 Replies View Related

How To Restrict Users To Particular Databases

Dec 16, 2006

While web hosting I use Sql Server 2000 as the database. Imagine I have hosted 3 Web Sites. All these 3 users want to modify/update their designs. What I did is I created respective 3 users having access to the respective databases only. So that they can registerd the ip and add to the Sql Server 2000 Enterprise Manager. These users are able to access their own databases only. But all these 3 users are able to access the default databases like master,pubs etc. How to restrict this.

Also suggest which is the optimal way to give control to the respective users while using Sql Server 2000.

====Suresh, P.R, Postal Training Centre, Mysore.

View 2 Replies View Related

How Do I Hide Databases From External Users?

Jan 31, 2003

I am going to give user rights for an external user to connect to my SQL Server via Client Network Utility.

Atlough I have given user permissions to only access one database and not the whole list, how do I make sure that they cannot see all the other databases on my SQL Server?

I have 20 instances of databases on my SQL Server and ideally I would like to give 20 different people access - but each of them when they enter my SQL Server, should not even know that the other databases exist.

Thanks.

View 6 Replies View Related

With User Sa I Can See Mot Databases How Can The Rest Of The Users See Them All?

Jun 26, 2007

I have a third party application that creates several databases on my sql server. This party uses the same user for accessing all this databases. However after moving to a new server this databases the user is no longer able to query them whith the exception of the "sa" user. Could anyone explain me how to add permissions to this databases manually so the user can query them again.

Thanks in advance

brgds

Miguel

View 3 Replies View Related

Query To Obtain Users And Privileges From Databases

Apr 24, 2007

Hi to all, is my first post, i need a query or script to obtain all users and privileges from all my databases, someone to help me. I'm learning Administration SQL server 2005.



I know that sys.database_principals and sys.server_principals have information about that, but i need users - privileges of every database.



thank you

View 4 Replies View Related

Server Level Role That Can Add / Alter Logins And Corresponding Users On All Databases

Jul 7, 2015

Does securityadmin Server level role can add, alter logins and corresponding users on all databases ? 

If not what is the best role other thn SA to have to manager logins and users.

View 4 Replies View Related

SQL Security :: Can Hide Databases From Users Who Don't Have Access In Management Studio

Apr 21, 2015

I have a client who would like to access his database via SQL Server Management Studio. I created a login for him. This login has access only to his database on the server (I set this up using the user mapping), the Securables has Connect to SQL checked (otherwise he won't see his database).  When I test this login, he is able to see all the other databases on the server, though when he clicks on the ones he doesn't have access to, it will tell him that he can't access that database.  He can access his database alright.  My question is, can I hide all the other databases from him, and only display that only database he has access to?  I have tried many different ways, I can't seem to be able to do so.

View 6 Replies View Related

How To Prevent Domain Admin Users From Accessing SQL 2000 Databases?

Mar 6, 2008

Based on our database infrastructure, we need to secure our SQL databases. The security issue concerns on allowing a limited number of Domain Admin users to access the SQL databases.
We tried certain ways, based on the documents in the Microsoft web site, but we couldn€™t reach to the point of preventing the Domain Admin users accessing the SQL databases.

Thanks in advance.

View 5 Replies View Related

SQL Server Admin 2014 :: Delete Orphans Users From Multiple Databases

Oct 21, 2015

I have a requirement to delete all the orphans users for the databases. The issue I am having is with when database principal owns a schema in the DB, User cannt be dropped.

How do I transfer it to DBO in case I am looping multiple databases. This is what I got so far .

declare @is_read_only nvarchar (200)
Select @is_read_only = is_read_only from master.sys.databases where name='test' /* This should be a parameter value */
IF @IS_READ_ONLY= 0
BEGIN
Declare @SQL as varchar (200)

[Code] .....

View 4 Replies View Related

Transact SQL :: Search For Users By Either Their Name Or Nickname

Oct 14, 2015

I am using a web service to search for users by either their name or their nickname. Users can type the persons name into a dot net text box that has a Autocomplete extender - which means it returns a list of user with each keystroke.

This works fine if I just search for a name.

select r.fname +' ' + r.lname
from users u
join log l
on l.riderid = u.riderid

where fname +' '+ lname like @item +'%'
group by l.fname , r.lname, nicknamellame

So if I am searching for Dan Brown When I enter a D I get all users whose name starts with D, A reduces the list to those that start with Da until you get a small enough list to find Dan Brown. This works - what I would like to allow is if they entered the users nickname (another column in the users table) it would also include those options: So, if Dan's nickname is DannyBoy typing that in would return the nickname.

select r.fname +' ' + r.lname
, nickname
from users u
join log m
on l.riderid = u.riderid
where (fname +' '+ lname like @item +'%')
or (nickname like @item + '%')
group by r.fname , r.lname, r.nickname
having max(l.[date]) >= '2014-01-01'

This does not work

View 4 Replies View Related

Transact SQL :: Loop - How To Get Data For Each Of Active Users

Jun 9, 2015

My insert statement for #Data - I only need to process each @EmployeeID one time, which is why I thought a loop would be sufficient, but I let this process run for 2 hrs and it still had not completed, so I feel I must have set-up something incorrectly!

This is my syntax, I am creating a table of active users, then wanting to get data for each of those active users.  But only get the data for each active user 1 time.

Declare @EmployeeID varchar(50)
CREATE TABLE #ActiveUsers
(
ID INT IDENTITY NOT NULL
,EmployeeID varchar(50)
,processed int
)
Create Table #Data

[Code] ....

View 5 Replies View Related

Transact SQL :: Number Of Distinct Users In Last 3 / 6 / 9 / 12 Months

Aug 26, 2015

I have table A(year int, month int, user varchar(20)), and I am trying to write a view that would show number of distinct users in the last 3 months, last 6 months, last 9 months and last 12 months(all from the most recent year/month) in following format:

3 months     6 months     9 months     12  months

number of distinct users        x                  y                  z                      w

View 20 Replies View Related

Transact SQL :: Stored Procedure For Total Count For New Users

Jul 14, 2015

I need to create a stored procedure for total count of the user's. If  User from front end  invites other user to use my tool, that user will be stored into a table name called "test",lets say it will be stored as"Invited 1 User(s)" or if he invites 2 users it will store into table as "Invited 2 User(s)."

But now we have changed the concept to get the ISID (name of the user)  and now when ever the user invites from the front end, the user who have invited should stored in two tables "test" and " test1" table .

After we get the data into test and test1 table i need the total count of a particular user from both tables test and test1.

if i invite a user , the name of the user is getting stored in both test and test1 tables.Now i want to get the count of a user from both tables which should be 1,but its showing 2.

Reason: Why i am considering the count from 2 tables is because before we were not tracking the usernames and we were storing the count in single test table.,but now we are tracking user names and storing them in both tables(test and test1).

Here is my sample  code:

I need to sum it up to get the total user's from both the table but I should get 1 instead of 2 

SELECT
(select distinct COUNT(*) from dbo.test
where New_Values like  '%invited%'
and Created_By= 'sam'
+
(select distinct count (*)  from dbo.test1
where invited_by ='sam'

View 8 Replies View Related

Transact SQL :: Database Audit Specification On Specific Users

Mar 30, 2015

Currently I am using SQL server 2012 and would like to implement database audit specification on specific users in my database. These are the users in my database name Payroll :-

PayrollAndy.Bred - db_owner
PayrollArpit.Shah - db_owner
Payrollwebapp - db_datareader, db_datawriter, EXECUTE
web_payroll - db_datareader, db_datawriter, EXECUTE

In my database audit specification settings, I would like to capture any SELECT,UPDATE,DELETE and EXECUTE command for users PayrollAndy.Bred & PayrollArpit.Shah only since they owned db_owner access. However, I am unable to capture any single command from both users. I do not want to put 'Principal' as public since I just want to capture both users activity.

Is it I miss out anything? Is it because of windows login account?

View 2 Replies View Related

Transact SQL :: Send Email To Multiple Users Based On A Column

May 15, 2015

I have a query running and returning 3 columns, user name, e-mail and device name

SELECT DISTINCT v_R_User.Full_User_Name0 AS 'User full Name', v_R_User.Mail0 AS 'E-Mail', _RES_COLL_DEV00144.Name
FROM         v_R_System INNER JOIN
                      v_R_User ON v_R_System.User_Name0 = v_R_User.User_Name0 INNER JOIN
                      _RES_COLL_DEV00144 ON v_R_User.User_Name0 = _RES_COLL_DEV00144.UserName INNER JOIN
                      v_GS_COMPUTER_SYSTEM ON v_R_System.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID
 Where v_R_User.Mail0 <> ''
ORDER BY 'User Full Name'

From here I would like to generate an e-mail to each user (like mail merge) to each user in the table an include their machine name. I can do it with PS, but rather have it run directly from SQL. Is it possible?

View 9 Replies View Related

Transact SQL :: Cleanup Suspect Databases

Sep 26, 2015

After cloning our production SQL 2012 server to make DEV environment, there is a bunch of databases in "Suspect" mode. This is because the DB's and Logs have got out of sync.I can clean up each DB with this script:

ALTER DATABASE DB_NAME SET EMERGENCY
GO
DBCC CHECKDB (DB_NAME)
GO
ALTER DATABASE DB_NAME SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
DBCC CHECKDB (DB_NAME, REPAIR_ALLOW_DATA_LOSS)
GO
ALTER DATABASE DB_NAME SET MULTI_USER
GO

but this takes a long time replacing DB_NAME and executing for each DB.I tried putting it all into a script with variables, but I have done something wrong and it does not work. Also is there a way to just apply it to the suspect DB's?

USE master
Go
DECLARE @dbname sysname, @cmd varchar(1000), @cmd1 varchar(1000), @cmd2 varchar(1000), @cmd3 varchar(1000), @cmd4 varchar(1000)
DECLARE db_recovery_cursor CURSOR FOR
SELECT name from sysdatabases
OPEN db_recovery_cursor

[code]....

View 7 Replies View Related

Transact SQL :: Getting Error When Trying To Union All Between Two Databases?

Nov 13, 2015

I am having an issue when trying to union all between two databases.

This is the error:

Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.

I have updated the collation in both DB to Latin1_General_CI_AS and I am still getting the error when running the query.

The queries run separately ok.  why I am still getting the collation error.

View 11 Replies View Related

Transact SQL :: List All File-groups For All Databases?

May 27, 2009

I would like to SELECT all filegroup on an SQL server instance, is that possible?Or only per database?

View 21 Replies View Related

Transact SQL :: Combining Two Queries From Different Linked Databases

May 20, 2015

I have 2 DBs located on separate Sql Servers but the DBs are linked. I am querying data from both DBs but want to combine the results. Here is my query but it doesn't seem to be working.

(SELECT DISTINCT
idname, name, address, address2, awardedtoname, suppno
FROM contract INNER JOIN
house ON contract.idname = house.idname)
JOIN
(SELECT DISTINCT
tpd.PropertyNumber AS [Property No], tpd.Address1 + ' , ' + tpd.Address2 AS Estate, tpd.Address1 AS Address1,

[Code] ....

How I could combine the results?

View 9 Replies View Related

Transact SQL :: How To Compare Columns On 2 Databases On 2 Different Servers

Aug 12, 2015

I need to compare columns in tables on 1 database on one server versus the same on a 2nd server.

I'm looking for added columns in dbase 1.

Is there a system T-SQL script that can be used for this?

View 4 Replies View Related

Transact SQL :: Script Not Running For Databases Other Than Master Database

Jun 5, 2015

Script only displays the result for 'Master' database. 

What changes are required for script to display result for all databases on the instance?

SELECT DB_Name() AS DatabaseName, OBJECT_NAME(ind.OBJECT_ID) AS TableName, 
ind.name AS IndexName, indexstats.index_type_desc AS IndexType, 
indexstats.avg_fragmentation_in_percent 
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats 
INNER JOIN sys.indexes ind  
ON ind.object_id = indexstats.object_id 
AND ind.index_id = indexstats.index_id 
WHERE indexstats.avg_fragmentation_in_percent > 30 and indexstats.page_count >1000
ORDER BY indexstats.avg_fragmentation_in_percent DESC

View 8 Replies View Related

Transact SQL :: Stored Procedure To Determine Which Databases To Restore?

Sep 27, 2015

I have 5 databases that the user will chose which ones to restore. I was thinking the variable with the 5 database names separated by commas. I was thinking about using the CONTAIN function but two of the databases have the same name except for a few letters at the end.

View 3 Replies View Related

Transact SQL :: How To Get All Databases Names With Its Owners In Server Instance

Jul 23, 2013

I want to get all databases with it's owner Name ,I think I need to join following script result with sys.databases or sys.sysdatabases.I want a result set  like this:

DatabaseName    db_Owner

master                  sa
pubs                     valia
pubs                     eli
pubs                    maryam
AdentureWork      eli

this script get all owners of the database that is in use:

Use DatabaseName
GO

SELECT  members.name MemberName, roles.name RoleName,roles.type_desc,members.type_desc

View 10 Replies View Related

Transact SQL :: Can Search All Databases And All Stored Procedures With A Certain Column Alias?

Oct 14, 2015

I am familiar with the sp_MSForEachDBand the USE Parameter I did Google and found [URL]

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved