tags:

views:

87

answers:

3

work on SQL Server 2000.i have CustomerDetails_Data.MDF file .from this file i want to take all information on my database .How to do?

A: 

What format do you want to extract the information to? You could write sql scripts against it, or use bulk copy.

Jeremy
+3  A: 

You will need to attach the .mdf data file to a database in SQL Server. Then you can simply query the information.

If you just have an .mdf file (and no log file .ldf), follow these steps to create a Database from your lone .mdf file:

  1. Create a new database with the same name and same MDF and LDF files

  2. Stop sql server and rename the existing MDF to a new one and copy the original MDF to this location and delete the LDF files.

  3. Start SQL Server

  4. Now your database will be marked suspect 5. Update the sysdatabases to update to Emergency mode. This will not use LOG files in start up

     Sp_configure "allow updates", 1
     go
     Reconfigure with override
     GO
     Update sysdatabases set status = 32768 where name = "BadDbName"
     go
     Sp_configure "allow updates", 0
     go
     Reconfigure with override
     GO
  1. Restart sql server. now the database will be in emergency mode

  2. Now execute the undocumented DBCC to create a log file

    DBCC REBUILD_LOG(dbname,'c:\dbname.ldf') -- Undocumented step to create a new log file.

(replace the dbname and log file name based on your requirement)

  1. Execute sp_resetstatus <dbname>

  2. Restart SQL server and see the database is online.

Mitch Wheat
SQL server will automatically generate the log file after attaching the database, no need to make it like this way...
Wael Dalloul
even in SQL Server 2000??
Mitch Wheat
yes even in SQL Server 2000
Wael Dalloul
OK, Thanks. ....
Mitch Wheat
A: 

You need to attach the .mdf data file to SQL Server, and SQL server will automatically generate a new LOG file, after that you can pass any query to the database...

Wael Dalloul