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!

help opening up MDF file.

Status
Not open for further replies.
Nov 28, 2002
121
US
I downloaded and installed sql2kdesksp3.exe
Installed it and have an Microsoft SQL server folder in my c:

I launched my sql server from my command line with required switches. I check my services and my sqlserver is on.

I have an .mdf file I'd like to look at.
How in the world do I open one up.

I read somewhere that I am supppose to attache the mdf file with visual studio 6.0

I currently have visual studio.net

Do I not have an SQL server interface with the version I installed on my machine?

wtf?

 
No MSDE does not come with a GUI. It only comes with the command line tools osql and isql. You need to use the sp_attach_db stored procedure to attach the mdf and ldf to the database. If you do not have the ldf and you only have the mdf file you can use the sp_attach_single_file_db stored procedure.

The syntax for both commands can be found in Books Online. (Start > Programs > Microsoft SQL Server > Books OnLine).

There shold be a service called MSSQLSERVER (Or something that starts with MSSQL$ that can be started so you don't have to start SQL manually from the command line.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
do I run the command from the command prompt?
My sqlserver is running in the background.
 
I don't have the ldf file.
I'll have to use the sp_attach_single_file_db
 
You run it from another command prompt. The window with the SQL Server running in it can't be used for anything else.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
I try running

EXEC sp_attach_single_file_db @dbname = 'db1',
@physname = 'D:\sqldata\db1_data.mdf'


but...EXEC is not recognized as internal or external command

Am I suppose to launch something for EXEC to be recognized?
 
I launched osql

Now, I created the database.
What sql statement do I use to list all tables within my database?
 
If you want to view the names of all the tables you can use the INFORMATION_SCHEMA views to do that.
Code:
select TABLE_NAME
from INFORMATION_SCHEMA.tables
I'd recommend looking at Books OnLine. It's full of good info on how to query the database.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top