SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Detach a database which is being replicated


Detach a database which is being replicated

Author
Message
m--S3qU3L
m--S3qU3L
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2616 Visits: 714
Hi friends,

Is it possible to detach a database, which is being replicated, without dropping publications.

Thanks

John
GSquared
GSquared
SSC Guru
SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)

Group: General Forum Members
Points: 184376 Visits: 9733
I don't think so, but I've never tried it. Set up a test on a dev box and see if it blows up.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
m--S3qU3L
m--S3qU3L
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2616 Visits: 714
Yep, Theres no straight method. But checking whether any smart ideas.
Thanks

John
GSquared
GSquared
SSC Guru
SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)SSC Guru (184K reputation)

Group: General Forum Members
Points: 184376 Visits: 9733
Why do you need to do this? It's possible there's another solution to the problem behind this.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
m--S3qU3L
m--S3qU3L
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2616 Visits: 714
There are huge lot of replication involved in huge lot of databases, which I'm planning to move.
So I think if I can get rid the replication rebuild, I can reduce the time window for the work.

We cannot make the DB offline or detach directly because its involved in REP.

I have an idea (Not sure its worth):
1. Make the DB RESTRICTED_USER
2. Excecute the ALTER DATABASE statement to reflect the new location.
3. Set the DB OFFLINE (Now its possible).
4. Move the file across.
5. Set the DB ONLINE (Now its up from the files at the new loc).

Not sure its worth and practical on production.

Hows itSmile bright or dump?

Thanks

John
Leo.Miller
Leo.Miller
SSCrazy Eights
SSCrazy Eights (9.4K reputation)SSCrazy Eights (9.4K reputation)SSCrazy Eights (9.4K reputation)SSCrazy Eights (9.4K reputation)SSCrazy Eights (9.4K reputation)SSCrazy Eights (9.4K reputation)SSCrazy Eights (9.4K reputation)SSCrazy Eights (9.4K reputation)

Group: General Forum Members
Points: 9394 Visits: 1597
Page9:F1 (11/18/2010)

So I think if I can get rid the replication rebuild, I can reduce the time window for the work.

We cannot make the DB offline or detach directly because its involved in REP.


Have you actually tried taking a replicated database off line?
Page9:F1 (11/18/2010)

I have an idea (Not sure its worth):
1. Make the DB RESTRICTED_USER
2. Excecute the ALTER DATABASE statement to reflect the new location.
3. Set the DB OFFLINE (Now its possible).
4. Move the file across.
5. Set the DB ONLINE (Now its up from the files at the new loc).

Not sure its worth and practical on production.

Hows itSmile bright or dump?

Thanks


Except for step 1, this is a perfectly good way to move databases and I have a project on this weekend that moves 2 X 500GB plus a few others on 3 servers databases this way. Moving them from old NAS storage to a new SAN.
With SQL 2005 you need to be careful of the DETACH because it changes some file permissions and even database configurations. e.g. if you detach a database that hase Database Ownership Chaining enabled, this will not be enabled when you attach again. (I've tested it). The reason being a detached database doesn't exist in sysdatabases, but an offline database does.

The onlys things I would do differently are:
a) Swap step 2 & 3
b) Do a copy of the files rather than a move. That way you have a quick fallback plan.
c) If you have the space and the move allows for this just rename the drives, but keep the logical location the same. This way you can avoif the alter database to move the logical files.

Cheers

Leo
dbamohsin
dbamohsin
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1432 Visits: 447
ive tested the above theory and works successfully with replication intact.

alter database REPTEST set restricted_user with rollback immediate;

ALTER DATABASE REPTEST SET OFFLINE;

ALTER DATABASE REPTEST
MODIFY FILE ( NAME = CMS, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\REPTEST\CMS.mdf' );
ALTER DATABASE REPTEST
MODIFY FILE ( NAME = CMS_log, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\REPTEST\CMS_log.ldf' );

-- Move the files at OS level

ALTER DATABASE REPTEST SET ONLINE;

alter database REPTEST set multi_user;

My DBA Ramblings - SQL Server | Oracle | MySQL | MongoDB | Access
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search