Thursday, March 29, 2012

Determine the database name

Hi

How do I determine the name of the database I am currently in ?

Thanks

Avi

select d.[name] from sys.sysprocesses p
join sys.databases d on d.database_id = p.dbid
where p.spid = @.@.spid|||

select d.[name] from master..sysprocesses p
join master..sysdatabases d on d.dbid = p.dbid
where p.spid = @.@.spid

Thanks

|||

Hi,

You can use db_name() for getting the name of the database

select db_name()

Eralper

http://www.kodyaz.com

No comments:

Post a Comment