Monday, 3 June 2013

TSQL to Attach a database with Rebuild New T-Log option


DBA’s often need to attach a database from SQL data file most of the cases provided by Vendor or during DR where T-Log does not have any significance, So we may well create a new log file instead of copying the log file over the network.

The TSQL used to attach a database with rebuild log option is given below,

CREATE DATABASE <dbname> ON (FILENAME = ‘<FilePath>) FOR ATTACH_REBUILD_LOG

Eg:-
CREATE DATABASE Testdb ON (Filename = ‘D:\Data\Testdb_data.mdf) FOR ATTACH_REBUILD_LOG

No comments:

Post a Comment