View Single Post

   
  #2 (permalink)  
Old 02-29-2008, 06:12 AM
Simon Hayes
 
Posts: n/a
Default Re: Is user logged-on?

You 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

Reply With Quote