This is probably an easy one but I'm banging my head against the wall trying to sculpture the perfect Google search. Anyway...
Is there a way to determine the current connection's database context? By database context, I mean the current database selected by the last USE or the default database for the user.
This may sound dumb (heck, don't you know the last USE statement you issued?) but I'm trying to debug a multi-threaded application and the context seems to be getting confused and I want to include some audit assert statements. Something like:
if @@DATABASE != 'Northwind' begin
RAISERROR 20000 'Database context is incorrect - currently ' + @@DATABASE + ', expecting Northwind'
RETURN(1)
end
insert into xyz...
Is there a way to determine the current connection's database context? By database context, I mean the current database selected by the last USE or the default database for the user.
This may sound dumb (heck, don't you know the last USE statement you issued?) but I'm trying to debug a multi-threaded application and the context seems to be getting confused and I want to include some audit assert statements. Something like:
if @@DATABASE != 'Northwind' begin
RAISERROR 20000 'Database context is incorrect - currently ' + @@DATABASE + ', expecting Northwind'
RETURN(1)
end
insert into xyz...
Comment