473,624 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 15439
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.goo gle.com...
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_si ngle_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****@sommarsk og.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****@sommars kog.se> wrote in message
news:Xn******** *************@1 27.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_si ngle_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****@sommarsk og.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
2350
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" namespace and a SqlConnection() object to connect to a local SQL Server 2005 Express database from within VB code contained in <SCRIPT /> tags in an ASP.NET page. I use Windows authentication (ie. "Integrated Security=SSPI;") to connect to the...
0
1212
by: Alan T | last post by:
How do I attach and detach a ContexyMenuStrip to a ListView at run time?
2
5141
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
14696
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 need to create another db with the same name. Thanks.
1
8491
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 using C# ? If yes, please illustrate.
2
4528
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 detach mdi child I use:
0
2509
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 steps: 1.) Open enterprise manager. 2.) All task and then attach database.
9
7803
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 T-SQL) and experience an error when attaching to the 2005 server: "CREATE FILE encountered operating system error 5 (error not found) while attempting to open or create the physical file 'xxxxxxxxxxxx' (Microsoft SQL Server, Error: 5123)" I have...
0
8231
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8672
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.