SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 ******How to select Logical database name*********
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

navmiester
Starting Member

3 Posts

Posted - 07/31/2007 :  20:37:32  Show Profile  Reply with Quote
Hi how do I select the current logical database name using a select statement.

Edited by - navmiester on 07/31/2007 20:39:08

rmiao
Flowing Fount of Yak Knowledge

USA
7266 Posts

Posted - 07/31/2007 :  22:47:00  Show Profile  Reply with Quote
What do you mean logical database name?
Go to Top of Page

jezemine
Flowing Fount of Yak Knowledge

USA
2875 Posts

Posted - 08/01/2007 :  00:17:38  Show Profile  Visit jezemine's Homepage  Reply with Quote
select db_name()


elsasoft.org
Go to Top of Page

rmiao
Flowing Fount of Yak Knowledge

USA
7266 Posts

Posted - 08/01/2007 :  11:40:02  Show Profile  Reply with Quote
This gives you real db name.
Go to Top of Page

eyechart
Flowing Fount of Yak Knowledge

USA
3575 Posts

Posted - 08/02/2007 :  01:56:00  Show Profile  Reply with Quote
quote:
Originally posted by navmiester

I do not want the dbname of the database I want the logical name. This can be obtained using the FileList only command. However I would like this to be done in a select statement if possible.




are you confusing database name with the logical names of the datafiles?

try the file_name function instead.



-ec
Go to Top of Page

rmiao
Flowing Fount of Yak Knowledge

USA
7266 Posts

Posted - 08/02/2007 :  22:50:38  Show Profile  Reply with Quote
Or get them from sys.sysfiles.
Go to Top of Page

navmiester
Starting Member

3 Posts

Posted - 08/09/2007 :  19:43:45  Show Profile  Reply with Quote
Thank you eyechart, I found the following code on a MSDN site

USE <Database name>
GO
SELECT FILE_NAME(1) AS 'File Name 1', FILE_NAME(2) AS 'File Name 2';
GO

quote:
Originally posted by eyechart

quote:
Originally posted by navmiester

I do not want the dbname of the database I want the logical name. This can be obtained using the FileList only command. However I would like this to be done in a select statement if possible.




are you confusing database name with the logical names of the datafiles?

try the file_name function instead.



-ec


Edited by - navmiester on 08/09/2007 19:44:28
Go to Top of Page

rmiao
Flowing Fount of Yak Knowledge

USA
7266 Posts

Posted - 08/09/2007 :  22:41:42  Show Profile  Reply with Quote
Those are logical file names, not db name.
Go to Top of Page

eyechart
Flowing Fount of Yak Knowledge

USA
3575 Posts

Posted - 08/09/2007 :  23:11:53  Show Profile  Reply with Quote
quote:
Originally posted by rmiao

Those are logical file names, not db name.




yeah, that is actually what he was looking for.



-ec
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000