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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 SQL Server logins
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 08/17/2004 :  10:27:48  Show Profile  Reply with Quote
Hi everybody,

I am constructing a dialog which prompts user for username and password to login to an SQL Server database. If another user on a different machine try to login with the same username, he will be ask if he wish to log out the old login first. If he choose yes, the old login will be logged out. My problem is that how can we know whether an SQL Server login is in use (has been logged by a different user)? And are there any ways to log out a logged SQL Server login?


Constraint Violating Yak Guru

United Kingdom
367 Posts

Posted - 08/17/2004 :  11:21:28  Show Profile  Reply with Quote
Look at using sp_Who, or sp_Who2, to see the logins currently connected to the server. If you find a name you want to disconnect, take the spid and issue the KILL command. Not neat, but it will do the trick.

Go to Top of Page

Aged Yak Warrior

583 Posts

Posted - 08/17/2004 :  11:35:42  Show Profile  Reply with Quote
Raymond gave all the hints. You may execute this as well.

SELECT * FROM  master.dbo.SysProcesses

Canada DBA
Go to Top of Page

Pointy Haired Yak DBA

4184 Posts

Posted - 08/17/2004 :  22:53:12  Show Profile  Visit derrickleggett's Homepage  Send derrickleggett an AOL message  Send derrickleggett a Yahoo! Message  Reply with Quote
Wouldn't you prefer to know if they "log out" of the application? This likely will not equate to a SQL Server login being maintained. For example, look at hotmail. I open hotmail and pull mail. Then I browse my favorite website, which is of course. Shortly thereafter, I decide to look at all my new SPAM graciously sent to me by the local porn providers. I don't have to relog in. I didn't maintain a connection to the database though. WOW How does this magic happen??????

They have a kewl little table called login_history (or some such nefarious object) which identifies the IP Address and a session key or something which is probably stored on my computer in one of those horrible cookies that will destroy your computer and walk off with your children.

If I login from another computer, it says "Who are YOU?". If I destroy my cookie, the cookie monster eats it, or I log off my internet browser, I have to magically log back in.

Yep....application security is the way to do it. It's a marvelous thing really. Those tables will help you though. Ask them for the SSN, birthday, and there most commonly used PIN number also to store in there.


When life gives you a lemon, fire the DBA.
Go to Top of Page

Starting Member

2 Posts

Posted - 08/18/2004 :  08:03:50  Show Profile  Reply with Quote
Thank you for your helps!
Go to Top of Page


United Kingdom
22859 Posts

Posted - 08/18/2004 :  13:45:06  Show Profile  Reply with Quote
How you've started something Derrick ... <g>

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2019 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000