Monday, May 30, 2011

DETTACH / attach in SQL SERVER 2000

| Monday, May 30, 2011 | 0 comments

DETTACH / attach in SQL SERVER 2000
You probably have done a copy of the database to other location by using a database backup Either attach or detach the database operation. Do you know what precisely Happen behind detach the database under the hood?
Detach the database Could Be done only if the database is not being accessed by anyone. If you Would like to make sure none accesses the database, you cans set the database to sql SINGLE_USER in ALTER DATABASE command with one of the termination options: WITH ROLLBACK AFTER n SECONDS WITH ROLLBACK IMMEDIATE or (Where n is a any integer number), for example:
ALTER DATABASE AdventureWorks2008
SET SINGLE_USER
WITH ROLLBACK AFTER 3 SECONDS
After That you cans sp_detach_db <databasename> issue (for example: EXEC sp_detach_db AdventureWorks2008).
Interesting thing to note Is That Pls detach a database is Issued, SQL Server will of copy dirty pages (pages changes since last checkpoint) back to corresponding pages in database files. You just only need to copy / move files into other database location for attaching the SQL Server database and transaction log files Could rebuild for you. But there are two conditions database That you need to be aware about.
If the database is read only, you need to include not only data files but Also Pls attach the transaction log file database. If the database is read write, you need only to include data files.
Since SQL Server 2005, the syntax for attach database is CREATE DATABASE ON <filespec> <database name> [, .... N] FOR {attach | ATTACH_REBUILD_LOG}. The legacy command sp_attach_db Should not be Used Because it Becomes depreciated features and Could Be removed in future SQL Server releases. The difference Between the new syntax and legacy Is That the maximum number of files on legacy is up to 16 files on the new syntax whereas the maximum number of files That Could be attached is up to 32.767 32.767 files and file groups. Certainly you will from never reach the number of files That need to be attached.
To me, attach-detach is as good as a backup-restore the database. The only difference Between Them Is That database is still accessible During the backup-restore whereas attach-detach requires a database to be offline.
** If my friends do not know what it means can translate on google
Bottom line:
DETTACH / Attach
Function: copying files to a server database and SQL Server menginisilisasi
How to Attach:
From Interprise Manager
Database
Right Click - All Task - Attach
Find the file *. MDF
How Dettach:
From Interprise Manager
Click on a database which is
Right click

0 comments:

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Post a Comment

thank you for visiting my blog and comment here. I hope the commentary contains a comment which intend to build and repair. criticism and suggestions I gladly accept.

Popular Posts

 

Total Pageviews

stat

© Copyright 2010. http://programminghaha.blogspot.com . All rights reserved | http://programminghaha.blogspot.com is proudly powered by Blogger.com | Template by o-om.com - zoomtemplate.com