Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 How to restrict Users from running SQL.

Author  Topic 

KPSQLServerCentralcom
Starting Member

2 Posts

Posted - 2012-08-31 : 15:33:24
We use SQL Server 2005. We have created a SQL Server Login called RUNSQLQUERYUSER. We have the following questions:

1. How to limit RUNSQLQUERYUSER from executing SQL queries using SQL Server Management Studio between 9:00 AM and 5:00 PM? How to implement that? Therefore if RUNSQLQUERYUSER runs a query at 8:00 AM we let them
but after 9:00 AM we don't let this user execute queries.

2. If RUNSQLQUERYUSER runs a SQL query before 9:00 AM but the query takes more than 30 minutes we need to stop it.

3. If RUNSQLQUERYUSER runs a SQL query before 9:00 AM but the query is still running at 9:00 AM we need to stop it.

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-31 : 18:30:39
run a scheduled job at 9 to grant required access to login and run a job by 5 pm to revoke it.


for stopping query check the execution time using dmv and then kill process

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-08-31 : 20:08:44
Alternatively you can use a logon trigger to prevent that user from even connecting to SQL Server during those hours. It has more flexibility than permissions as you can also check which application it's using, which machine it's connecting from, etc.

You can read more about them here: http://msdn.microsoft.com/en-us/library/bb326598.aspx

And for future reference, if you upgrade to SQL Server 2008 Enterprise Edition, you can use the Resource Governor to control how many resources are used for certain users/connections.
Go to Top of Page
   

- Advertisement -