Friday, February 24, 2012

Find "current database"

what is the SQL to find
1) current database
2) server name
like one can do in Oracle like:
select user from dua;
select * from v$instance;
thanksklabu wrote:
> what is the SQL to find
> 1) current database
> 2) server name
> like one can do in Oracle like:
> select user from dua;
> select * from v$instance;
>
> thanks
SELECT DB_NAME() AS db_name;
SELECT SERVERPROPERTY('MachineName') AS MachineName;
SELECT SERVERPROPERTY('InstanceName') AS InstanceName;
SELECT SERVERPROPERTY('ServerName') AS ServerName;
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||thanks
how to concat them values ?[vbcol=seagreen]|||klabu wrote:[vbcol=seagreen]
>thanks
>how to concat them values ?
Select @.@.Servername returns current server as well.

No comments:

Post a Comment