Attach a MDF file without the LDF

8. December 2006

A friend asked me about this and here where two answers.  We used the first one listed first time around.  You should see the differences between the solutions.

 

 

The stored procedure is under the Master database. -RDC

A single-file database is a database that have only one data file. When a database comprises only one data file, the database can be attached to an instance of SQL Server 2000 without using the transaction log file. When the data file will be attached, SQL Server will create a new transaction log file automatically.

To attach a single-file database, you can use the sp_attach_single_file_db system stored procedure. The syntax for sp_attach_single_file_db system stored procedure is as follows:

sp_attach_single_file_db [ @dbname = ] 'dbname' 
    , [ @physname = ] 'physical_name'

      
      
      • [@dbname =] 'dbname' is the database name. 'dbname' is nvarchar(128), a default value is NULL.
      • [@physname =] 'phsyical_name' is the database file name. 'phsyical_name' is nvarchar(260), a default value is NULL.

      This is the example to attach only one data file of the pubs database from the C:\MSSQL\Data directory:

      EXEC sp_attach_single_file_db @dbname = 'pubs',
           @physname = 'C:\MSSQL\Data\pubs.mdf'
      
      
      >
      
    1. Link to How to attach a MDF file without the LDF ยป ServerTastic Blog

Tips and Tricks

Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading