SQL DB – Attach .mdf file without .ldf file

There are many way to attach an .mdf file (primary database file) without an .ldf file (transaction log file),  the following are two examples:

First method:

EXEC sp_attach_single_file_db @dbname='TestDb',
@physname=N'C:\DB_Folder\SYSNEWBIE_DB.mdf'
GO

Second method:

CREATE DATABASE SYSNEWBIE ON
(FILENAME = N'C:\DB_Folder\SYSNEWBIE_DB.mdf')
FOR ATTACH_REBUILD_LOG
GO

 

I hope it will be useful for you, see you soon!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s