Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine if User is already logged in

Status
Not open for further replies.

Toyman

Programmer
Jun 19, 2001
68
GB
Hi
I'am using VB and ADO to connect to SQL....
Is there a way to check that the login I'am using, not
already logged in.

Thanks
Toyman
 

First, there are a couple of things you need to remember.[ol][li]You have to be able to login to check.
[li]A user may have multiple connections for the same process or connections with the same login for different processes.[/ol]To count the number of SQL connections for the current login.

select RecCnt=count(*)
from master..sysprocesses p join master..syslogins l on p.sid=l.sid
where l.name=user_name()

To count the number of SQL connections for a specific login.

select RecCnt=count(*)
from master..sysprocesses p join master..syslogins l on p.sid=l.sid
where l.name='login_name' Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it if you have time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top