SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 How to restrict Users from running SQL.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

KPSQLServerCentralcom
Starting Member

2 Posts

Posted - 08/31/2012 :  15:33:24  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 08/31/2012 :  18:30:39  Show Profile  Reply with Quote
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

USA
15663 Posts

Posted - 08/31/2012 :  20:08:44  Show Profile  Visit robvolk's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000