November 13, 2017 at 11:22 am
Why is detach/attach not recommended for moving a user database?
November 13, 2017 at 11:40 am
It's no longer needed for moving files around on the same instance. Instead you can update the master catalog with the file locations, take the db offline, move the files, and bring the db back online. That is easier and safer than detach & attach.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
November 13, 2017 at 11:54 am
Either method will work, but as Scott mentioned, there isn't a need to detach the databases anymore.
November 13, 2017 at 12:10 pm
ScottPletcher - Monday, November 13, 2017 11:40 AMIt's no longer needed for moving files around on the same instance. Instead you can update the master catalog with the file locations, take the db offline, move the files, and bring the db back online. That is easier and safer than detach & attach.
Thanks for answering. I see the easier part. Why is it safer?
November 13, 2017 at 12:24 pm
I'd say it's slightly safer as none of the meta data for the db is removed and added back. If there were some issue, you might have an issue doing the attach.
For me, I don't consider detach/attach unsafe, but it adds a very small amount of risk that isn't necessary.
November 13, 2017 at 12:28 pm
Steve Jones - SSC Editor - Monday, November 13, 2017 12:24 PMI'd say it's slightly safer as none of the meta data for the db is removed and added back. If there were some issue, you might have an issue doing the attach.For me, I don't consider detach/attach unsafe, but it adds a very small amount of risk that isn't necessary.
Curiosity satisfied. Thank you.
November 13, 2017 at 12:33 pm
Other issues:
1) if there's an error in a db file (such as would show up in a DBCC CHECKDB), it won't reattach
2) during a reattach, the file gets modified. if the reattach fails for any reason, even once you correct that error, the db may not reattach with the same files. You'll need copies of the original files. In short, to safely use the attach method, you must first make copies of the files to be attached in case the attach fails.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
November 14, 2017 at 6:01 am
rchantler - Monday, November 13, 2017 11:22 AMWhy is detach/attach not recommended for moving a user database?
There won't be an easy way out, if binaries get corrupted and it doesn't allow restore with the old DB Name. Experts might put more proper points as have done above.
December 8, 2017 at 6:02 am
This was removed by the editor as SPAM
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply