473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

detach database, attach database without log file

DBA
If I detach a database on a server, then attach the database with a
single file only using the data file...will I lose any transactions
that were in the original log file? There is a debate going on here at
work where some people think that during the detach, transactions in
the log file are saved to the data file.

Thanks!
Jul 20 '05 #1
4 15415
Hi

You will not loose any committed transactions.

Uncommitted transactions will normally be rolled back rolled back even if
you attached the log file!! If this did happen it would be indicated in the
SQL Server log file.

John

"DBA" <ka******@yahoo.com> wrote in message
news:ff**************************@posting.google.c om...
If I detach a database on a server, then attach the database with a
single file only using the data file...will I lose any transactions
that were in the original log file? There is a debate going on here at
work where some people think that during the detach, transactions in
the log file are saved to the data file.

Thanks!

Jul 20 '05 #2
DBA (ka******@yahoo.com) writes:
If I detach a database on a server, then attach the database with a
single file only using the data file...will I lose any transactions
that were in the original log file? There is a debate going on here at
work where some people think that during the detach, transactions in
the log file are saved to the data file.


If the database is shut down cleanly, there will be nothing to lose.
If the database feels that there is something that needs to be rolled
forward or backward it will cry out for the log, and
sp_attach_db_single_file will not succeed. If you at this point to not
have the log file around anywhere, you are in trouble.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
I believe sp_detach_db will ensure no transactions need to be rolled forward
or back. Consequently, the log isn't needed when attaching a database with
a single log file that was properly detached.

Attaching a database that wasn't properly detached is a crap shoot because
SQL Server might need the log to roll transactions forward/back. The
frequent newsgroup postings from folks who've tried this and failed are the
proof.

In any case, I'd keep the log and/or backups around until the database was
successfully attached.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:Xn*********************@127.0.0.1...
DBA (ka******@yahoo.com) writes:
If I detach a database on a server, then attach the database with a
single file only using the data file...will I lose any transactions
that were in the original log file? There is a debate going on here at
work where some people think that during the detach, transactions in
the log file are saved to the data file.


If the database is shut down cleanly, there will be nothing to lose.
If the database feels that there is something that needs to be rolled
forward or backward it will cry out for the log, and
sp_attach_db_single_file will not succeed. If you at this point to not
have the log file around anywhere, you are in trouble.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Jul 20 '05 #4
Thanks everyone for your contributions! I chose to shutdown the
application, backup the database, restore the database on the
destination, and then delete the original db. I felt that this was safer
than risking any problems during the detach.

Thanks for the info!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Loane Sharp | last post by:
Hi there I had no luck in getting the following question answered in the SQL Server newsgroups. Please point me in the right direction. Background: I am using the "System.Data.SqlClient"...
0
by: Alan T | last post by:
How do I attach and detach a ContexyMenuStrip to a ListView at run time?
2
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
so I notice to detach a database you use Server svr = new Server(); svr.DetachDatabase("MyDatabase"); but is there a way you can set where its saved after detaching ? thansk
3
by: rdraider | last post by:
Everything I read about sp_resetstatus says you must restart SQL after. Is there a way around that (don't want to shut down production). The suspect db is just an empty db that is not needed. I...
1
by: RP | last post by:
I am using SQL Server 2005 with C# 2005. I want to programmatically Detach a database, then copy its files from the data folder to another location and then Attach the database back. Can it be done...
2
by: Marina | last post by:
We have MDI WinForms C# .Net2 application. Parent form has MdiContainer=true; Children forms are created like this: Form child = new Form(); child.MdiParent = this; child.Show(); To...
0
by: Lexxzy | last post by:
Hi to all, I've a problem about to attach a recovered database file in the enterprise manager. My problem goes this way, I want to attach a recovered database file. So when I followed this...
9
by: dpatel75 | last post by:
I am trying to copy a database from a SQL 2000 SP3 Windows 2000 server to a 2005 SP2 Windows 2003 server. I am trying to use detach and attach method (have tried both within Management Studio and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.