Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 database

Author  Topic 

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2006-03-16 : 04:41:03
Hi,
1)How can I get the names of the databases in sql server 2005?
2)How can I get the names of the sql server machines?

Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-16 : 04:58:12
1)
for current database name
select db_name()

for all databases
select name from master..sysdatabases


2)

select serverproperty('machinename')




KH


Go to Top of Page

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2006-03-16 : 05:11:40
Hi,
For question 2)
how about if there is an instance name?
For example:
select serverproperty('machinename')
returns server1
but I should have server1\instance1

Thanks
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-16 : 05:15:53
select @@servername, serverproperty('servername')




KH


Go to Top of Page
   

- Advertisement -