Wednesday, 23 April 2014

Get Current Database Name SQL Server

Get Current Database Name SQL Server
Current Database Name
SELECT DB_NAME()
All Database names in the server
select name from sys.databases
Name of the SQL Server
SELECT SERVERPROPERTY('MachineName') AS MachineName
SELECT SERVERPROPERTY('ServerName') AS ServerName
Select SERVERPROPERTY('ComputerNamePhysicalNetBIOS') as PhysicalName
SELECT @@SERVERNAME AS ServerNameGlobalVar