SQL Server attaches a database file without a log file to the servers

Source: Internet
Author: User
Tags mssqlserver

Today made a very annoying thing, accidentally put a 40 more g of the database log files deleted, and before the deletion I made a log in, dead or alive can not attach to the server has been prompted multiple logs cannot be automatically created, wasted a night of my time, and then constantly Google, Finally in a foreigner's blog found a few statements, directly, thank him on the way to record.

Use [master]go--Method 1:i with this methodexec sp_attach_single_file_db @dbname = ' TestDb ', @physname =n ' C:\Program files\ Microsoft SQL Server\mssql10. Mssqlserver\mssql\data\testdb.mdf ' go--Method 2:create DATABASE TestDb on (FILENAME = N ' C:\Program Files\Microsoft SQL Server\mssql10. Mssqlserver\mssql\data\testdb.mdf ') for Attach_rebuild_loggo

Statement 1 is to attach the file to the database, and if something like this happens to me. Therefore, the execution of statement 2 can be re-established log, tube several log files.

-- Method 3: CREATE DATABASE  on  = N'C:\Program Files\Microsoft SQL Server\mssql10. Mssqlserver\mssql\data\testdb.mdf') for ATTACHGO

Not to add this, basically all the solution, thank God, or play!

SQL Server attaches a database file without a log file to the servers

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.