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
 General SQL Server Forums
 New to SQL Server Programming
 how to get database name

Author  Topic 

mthassan
Starting Member

2 Posts

Posted - 2012-11-02 : 09:32:24
Dear Experts.
I am using sql server 2000 and 2005. I want get database name when I attach database with sql server. like as you see when we attach database through enterprise manager and when we select database from drive to attach its show database name in attach as ...text box.
remember it this data base was attached before.. I detach it and again
attach it. It shows his name automatically in attach as box that was set before when was attached first..
that name I want get when I try to attach database through sqldmo..
How to determine which name was when this database was attached...


thanks in advance

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-11-02 : 10:18:06
Maybe this?
select db_name()

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

mthassan
Starting Member

2 Posts

Posted - 2012-11-03 : 01:22:02
Dear Sir.
Problem has solved with following command..Please remember that MDF file should not attach with sql server
DBCC checkprimaryfile(N'D:\MY_DATA.MDF', 2)

thanks & regardgs
Go to Top of Page
   

- Advertisement -