Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / SQL / November 2008

Tip: Looking for answers? Try searching our database.

Logical names of the databases

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tshad - 13 Nov 2008 23:27 GMT
I know how to get the logical name of a database from the backups (RESTORE
FILELISTONLY), but how do I get it from the database itself?

Thanks,

Tom
Tom Moreau - 13 Nov 2008 23:39 GMT
Could you be more specific?  Would the following work:

select
   db_name()

Signature

  Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON   Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau

I know how to get the logical name of a database from the backups (RESTORE
FILELISTONLY), but how do I get it from the database itself?

Thanks,

Tom
Dan Guzman - 14 Nov 2008 02:14 GMT
Do you mean list the logical file names of an existing database?  In that
case, try sp_helpdb:

EXEC sp_helpdb 'MyDatabase'

Signature

Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

>I know how to get the logical name of a database from the backups (RESTORE
>FILELISTONLY), but how do I get it from the database itself?
>
> Thanks,
>
> Tom
tshad - 17 Nov 2008 21:27 GMT
> Do you mean list the logical file names of an existing database?  In that
> case, try sp_helpdb:
>
> EXEC sp_helpdb 'MyDatabase'

That was it.

I just wanted to be able to find the Logical name so I could use that to
change the logical name to match the DB name when I use a different Backup
to restore the database.

It seems to be in the second set of data that comes back where I assume the
name = Logical name and the filename is the actual db files.

Thanks,

Tom

>>I know how to get the logical name of a database from the backups (RESTORE
>>FILELISTONLY), but how do I get it from the database itself?
>>
>> Thanks,
>>
>> Tom
Dan Guzman - 18 Nov 2008 12:31 GMT
> It seems to be in the second set of data that comes back where I assume
> the name = Logical name and the filename is the actual db files.

If you don't the other information, one method to list only the files is
sp_helpfile:

USE MyDatabase
EXEC sp_helpfile

You can also get this information with SELECT * FROM sys.database_files.

Signature

Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

>> Do you mean list the logical file names of an existing database?  In that
>> case, try sp_helpdb:
[quoted text clipped - 20 lines]
>>>
>>> Tom
tshad - 20 Nov 2008 00:23 GMT
>> It seems to be in the second set of data that comes back where I assume
>> the name = Logical name and the filename is the actual db files.
[quoted text clipped - 6 lines]
>
> You can also get this information with SELECT * FROM sys.database_files.

I'll look at those as well.

Thanks,

Tom

>>> Do you mean list the logical file names of an existing database?  In
>>> that case, try sp_helpdb:
[quoted text clipped - 20 lines]
>>>>
>>>> Tom
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.