Friday, October 16, 2015

SQL Query for Attaching databases in Post Office

At the time of formatting the server restoring of each database is very big process. To simplify this work we can attach databases. This combine query may be useful for attaching databases while formatting the server in Sub Offices.

Note:This query prepared in the view of databases created in D Drive. If your databases are present other than D Drive, paste this query in notepad and replace the path of mdf and ldf files. ( Example:D:\ with E:\). And also the query is prepared in the view of Sub Office Server only.

Query for Attaching the databases

Select and Copy the below query then execute in Query Analyzer. Note: Check whether the database names are correctly entered. If any difference between available database and the below query you just edit the database name in below  query then execute.

exec sp_attach_db 'BOSUBACCOUNTS','D:\BOSUBACCOUNTS_dat.mdf','D:\BOSUBACCOUNTS_log.ldf'
go
exec sp_attach_db 'BOSUPPLYSUBACCOUNTS','D:\BOSUPPLYSUBACCOUNTS_dat.mdf','D:\BOSUPPLYSUBACCOUNTS_log.ldf'
go
exec sp_attach_db 'COUNTER','D:\Counter.mdf','D:\Counter.ldf'
go
exec sp_attach_db 'ECOUNTER','D:\ECounter.mdf','D:\ECounter.ldf'
go
exec sp_attach_db 'EMO','D:\eMO.mdf','D:\eMO.ldf'
go
exec sp_attach_db 'IPO','D:\IPO.mdf','D:\IPO.ldf'
go
exec sp_attach_db 'NICPLI','D:\NICPLI.mdf','D:\NICPLI.ldf'
go
exec sp_attach_db 'POSPCC','D:\POSPCC.mdf','D:\POSPCC.ldf'
go
exec sp_attach_db 'POSPCCBACKUP','D:\POSPCCBACKUP.mdf','D:\POSPCCBACKUP.ldf'
go
exec sp_attach_db 'POSTMAN','D:\Postman.mdf','D:\Postman.ldf'
go
exec sp_attach_db 'ROUTING','D:\ROUTING.mdf','D:\ROUTING.ldf'
go
exec sp_attach_db 'SUBACCOUNTS','D:\SUBACCOUNTS_dat.mdf','D:\SUBACCOUNTS_log.ldf'
go
exec sp_attach_db 'SUBTREASURY','D:\SUBTREASURY_dat.mdf','D:\SUBTREASURY_log.ldf'
go
exec sp_attach_db 'SUPPLYSUBACCOUNTS','D:\SUPPLYSUBACCOUNTS_dat.mdf','D:\SUPPLYSUBACCOUNTS_log.ldf'
go
exec sp_attach_db 'TREASURY','D:\TREASURY_dat.mdf','D:\TREASURY_log.ldf'
go
exec sp_attach_db 'BPLOG','D:\POST\bplogdata.dat','D:\POST\bploglog.dat'
go
exec sp_attach_db 'BPRO','D:\POST\bprodata.dat','D:\POST\bprolog.dat'
go
exec sp_attach_db 'NREGAEMO','D:\POST\NREGAEMO_Data.MDF','D:\POST\NREGAEMO_Log.LDF'
go
exec sp_attach_db 'POST','D:\POST\postdata.dat','D:\POST\postlog.dat'
go
exec sp_attach_db 'PROJECT','D:\POST\projectdata.dat','D:\POST\projectlog.dat'
go
exec sp_attach_db 'SIGN','D:\POST\signdata.dat','D:\POST\signlog.dat'
go
exec sp_attach_db 'SOSB','D:\POST\sosbdata.dat','D:\POST\sosblog.dat'
go
Thanks to DOPCorner 

No comments:
Write Comments