Results 1 to 15 of 15

Thread: How to kick everyone off SQL server

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    How to kick everyone off SQL server

    Hi,

    How do I disable all remote connections to SQL server, but keep the local connection working.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to kick everyone off SQL server

    By the local connection you mean like your connection while in enterprize manager?

    If you mean remotely connected servers to your server then clear the Allow other SQL Servers to connect remotely to this SQL Server using RPC check box.
    Last edited by RobDog888; Mar 30th, 2006 at 06:22 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Re: How to kick everyone off SQL server

    Sorry wasn't very clear at all.

    I'm physically sat on the server (well not literally, as that would be silly) and for example I want to restore a backup copy of the database. To do this I want to remove all other connections bar my own, is there an easy way to do this? And then stop new connections being made.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to kick everyone off SQL server

    Yes, there is but I dont have access to the Enterprize Manager interface right now as my host doesnt allow me admin permissions in it.

    Perhaps a quick search at MS will turn up a KB Article.

    Sorry, I too wish I had Admin access right know and I could find out easily.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: How to kick everyone off SQL server

    Did you try looking at sp_configure procedure. There are two options that might help you user connections and remote access, although I have never tried this myself.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to kick everyone off SQL server

    I came across that sp too but I know there is a easy way in EM to do it.
    Do you have access to EM currently?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: How to kick everyone off SQL server

    In EM, right click on the Server, select properties. IN the resulting dialog select Connections tab and in the bottom of the dialog ucheck "Allow other SQL Servers to connect remotely to this SQL Server using RPC".

    @Rob: Is this what you are looking for?
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to kick everyone off SQL server

    Almost. That prevents other SQL servers from connecting but he needs to prevent and disconnect other connections to his db except for himself.

    So if an app is connected he wants it to disconnect so he can make a backup. Although an online backup is ok to perform depending on the user load.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How to kick everyone off SQL server

    If you are looking to not allow other users in the DB then

    Right click on the DB in EM - select properties - go to the OPTIONS tab and

    "restrict access" - you have two choices - Members of dbo... or Single User.

    But I'm concerned about what you want to do - RESTORE a DB? Are you going to RESTORE a .BAK into an existing DB or drop the DB and restore the .BAK to make a new DB?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: How to kick everyone off SQL server

    I think I found it.... but it's not easy....
    From EM, expand the following nodes:
    _Your_Server_ -> Management -> Current Activity.
    Click Current Activity, then right click on each of the current processes that are in your database and "Kill Process" ... however.... it's a dangerous thing to do. We do this alot around here and just find it easier to ask everyone to get out of the pool (so to speak) and then do the restore.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Re: How to kick everyone off SQL server

    The database restore was more of an example.

    The scenario is I tell everyone to get of the database for the next 10 minutes. But during this 10 minutes some numpty will try and gain a connection which I don't want, so short of unplugging the network cable how do I stop this.

  12. #12
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How to kick everyone off SQL server

    We put that control into our app from the start. It looks at a configuration table and can tell the users that the system is turned off at the moment or that the client app version level has changed - and they need the new version to continue.

    Are you talking about a single client app at this point?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  13. #13
    Member
    Join Date
    Jan 2006
    Location
    UK
    Posts
    61

    Re: How to kick everyone off SQL server

    Hi

    Open the enterprise manager. Go to the properties dialog for the database. Select Restrict access/single user.

    Now take the database offline (right click the database and you will get this option). This will force a checkpoint, keeping the integrity of your data. No users will lose data (as they may do if you do something drastic such as pulling out the network cable).

    Bring it back online. Back it up (or whatever else you need to do). Now uncheck the Restrict access option.

    Hope this helps

  14. #14
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: How to kick everyone off SQL server

    Quote Originally Posted by Oliver1
    Hi,

    How do I disable all remote connections to SQL server, but keep the local connection working.
    Execute the following TSQL

    Code:
    ALTER DATABASE NAME_OF_DB_HERE SET SINGLE_USER WITH ROLLBACK

  15. #15
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: How to kick everyone off SQL server

    Take the server off the network.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width