Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing MDF file

Status
Not open for further replies.

be1s

Programmer
Dec 8, 2003
59
0
0
US
I have a third party application that has both a server installation and a client installation. When I did the server installation on the DB server (which use SQL Server MSDE) it installed an .mdf and .ldf files. That works fine. However, how do I create a database to view the mdf file?

Thanks in advance for your help

Bels.


 
If the App put the mdf and ldf file there then the database has already been created. The mdf file holds all the data, and the ldf is the transaction log for the database. Together they make up the database.

With only MSDE you are limited to the tools that it comes with. You'll need to use isql to connect to the database via command line to query and manage the database.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Thanks for such an immediate response.

Connect to the database....is that the same as saying attach to a database?
 
I beleive the word "attach", and its counterpart "detach" are actually commands that bring a database file (MDF), and in most cases the associated transaction file (LDF), online and able to be queried and worked with.

We us the stored procedures sp_detach_db and sp_attach_db to do these operations in Query Analyzer. They can also be perfored in Enterprise Manager.

Establishing a "connection" is what a person does to gain access to the DB.

Thanks

J. Kusch
 
To see if the database is available, connect to the database using isql. The connection string will be something like this.
Code:
isql -S {ServerName} -E

This will connect to the server named {ServerName} using your windows account to login.

Then run the following command.
Code:
select name
from master.dbo.sysdatabases
where name = '{DatabaseNAme}'
go
You can get the {DatabaseName} from the vendor. Leave the single quotes around the database name.

If at the bottom it says (1 row affected) then the database is attached and ready for use. If it says (0 rows affected) it is not attached (or it's attached under a different name).

You can use the sp_attach_db procedure to attach the database. The full syntax is available in Books OnLine (Start > Programs > Microsoft SQL Server > Books OnLine).

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top