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.
| Author |
Topic |
|
navmiester
Starting Member
3 Posts |
Posted - 2007-07-31 : 20:37:32
|
| Hi how do I select the current logical database name using a select statement. |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-07-31 : 22:47:00
|
| What do you mean logical database name? |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-08-01 : 11:40:02
|
| This gives you real db name. |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2007-08-02 : 01:56:00
|
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 |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-08-02 : 22:50:38
|
| Or get them from sys.sysfiles. |
 |
|
|
navmiester
Starting Member
3 Posts |
Posted - 2007-08-09 : 19:43:45
|
Thank you eyechart, I found the following code on a MSDN siteUSE <Database name>GOSELECT FILE_NAME(1) AS 'File Name 1', FILE_NAME(2) AS 'File Name 2';GOquote: 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
|
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-08-09 : 22:41:42
|
| Those are logical file names, not db name. |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2007-08-09 : 23:11:53
|
quote: Originally posted by rmiao Those are logical file names, not db name.
yeah, that is actually what he was looking for.-ec |
 |
|
|
|
|
|