Friday, March 30, 2012

Is user logged-on?

Dear Group

I wondered whether there's a function or script that will show me
whether a user is currently logged-on to a MSSQL 2000 database? I'm
using SQL Authentication.

Thanks very much for your help & efforts!
Have a nice day!

MartinYou can use sp_who or sp_who2, or if you need something from code then
a statement like this will work:

if exists (select * from master.dbo.sysprocesses
where loginame = 'MyLogin'
and dbid = db_id('MyDB'))
begin
/* Do something here */
end

Simon|||Hi Simon!

Thanks for the message. Works great!

M

No comments:

Post a Comment