Wednesday, September 29, 2010

Backup was aborted...

Failed to pause catalog for backup.
Today I was trying to backup some database on one box, but there was some error with only one database.
It was Failed to pause catalog for backup
1. Jump to the services console. (Control Panel-> Administrative Tools -> Services)
2. Locate the SQL Server FullText Search and verify is it running.
3. If it is not running then start it .... but hold on read the next point
4. If it is running then verify what account which it is using under Log On tab.  (it should be Local System Account)
5. Save the settings and make sure to restart the service and you are done.

Saturday, September 25, 2010

Attach and Detach Database

--HOW TO ATTACH AND DETACH DATABASE FILES

select * from sys.database_files
--read the physical_name of current location of the database before detach
EXEC SP_DETACH_DB N'DATABASENAME'
--database is detached so now go to the loction where the (mdb,ldb) file is located and move to new location copy that new location
EXEC SP_ATTACH_DB N'DATABASENAME' , 'NEW_LOCATION_DATA.mdb', 'NEW_LOCATION_LOG.ldb'
--run the below commant to see the new changes
SELECT * FROM SYS.DATABASE_FILES

Attach and Detach Database

--HOW TO ATTACH AND DETACH DATABASE FILES

select * from sys.database_files
--read the physical_name of current location of the database before detach
EXEC SP_DETACH_DB N'DATABASENAME'
--database is detached so now go to the loction where the (mdb,ldb) file is located and move to new location copy that new location
EXEC SP_ATTACH_DB N'DATABASENAME' , 'NEW_LOCATION_DATA.mdb', 'NEW_LOCATION_LOG.ldb'
--run the below commant to see the new changes
SELECT * FROM SYS.DATABASE_FILES

Moving Database Files Using Alter Database

--HOW TO MOVE THE LOCATION OF THE DATABASE USING ALTER DATABASE (similar to attach and detach work)
SELECT * FROM SYS.DATABASE_FILES
--read the physical_name of the current location of the database before moving the database files
ALTER DATABASE DATABASENAME
MODIFY FILE (NAME = 'NAME' , FILENAME = 'NEW_LOCATION.mdb');
ALTER DATABASE DATABASENAME
MODIFY FILE (NAME = 'NAME' , FILENAME = 'NEW_LOCATION.ldb');
--the above command have moved the database file locially now need to move it physically
--before moving the file physically to new location put the database in OFFLINE mode
--run the below statement to make database in OFFLINE mode
ALTER DATABASE DATABASENAME SET OFFLINE
--now move the database file physically to its new location after moving run the below statement
ALTER DATABASE DATABASENAME SET ONLINE
--run the below commant to see the new changes
SELECT * FROM SYS.DATABASE_FILES
--Note its more convient then Attach and Detach