Showing posts with label detaching. Show all posts
Showing posts with label detaching. Show all posts

Sunday, March 11, 2012

copy database

I have copied a Database from one server to another server by detaching and attaching.Everything looks fine but i didn't get the logins associated with the DB onto new server.
How can i get those logins into the database on new server.
Thanks.Search this forum and www.sqlteam.com for sp_help_revlogin. You can run that script and it will produce all the logins with the correct SIDs.|||where should i run this script?on the source server or destination server?|||Run it on the source server. It will give you a permissions script to run on the destination server.

copy database

I wanted copy a database from one server to another server.So far I'm doing this is by detaching and attaching the DB.But when i tried to restore the DB on the new server its giving some error. Is't a good process to detach and attach.PLease let me know if there is any better way of doing this.BACKUP DATABASE database_name
TO DISK = '\\server\share\folder\whatever.bak'

Copy file

RESTORE DATABASE database_name
FROM DISK = '\\server\share\folder\whatever.bak'|||Thanks for ur information.So, is't a bad practice to attach and detach the DB ...|||Thanks for ur information.So, is't a bad practice to attach and detach the DB ...

No, it's ok...and fatser...

But the destination db must already exists, and already be detached...

The restore will create one where one doesn't exist|||Even I have tried to do the same with copy database wizard but it was generating some problems.So i was doing this with attach and detach.However my aim is to copy this database to another server and to have the database available on both the servers.

Thanks.|||Yeah...I have a scheduled job that does that every night...it executes this sproc

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_Restore_Production]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[usp_Restore_Production]
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

Create Proc usp_Restore_Production as

ALTER DATABASE TaxReconDB_Prod SET SINGLE_USER WITH ROLLBACK IMMEDIATE

RESTORE DATABASE TaxReconDB_Prod
FROM DISK = 'D:\Tax\BackUp\TaxReconDB.dmp'
WITH MOVE 'TaxReconDB_Data' TO 'D:\Database\NJROS1D151DEV\MSSQL$NJROS1D151DEV\Dat a\TaxReconDB_Prod_Data.MDF'
, MOVE 'TaxReconDB_Log' TO 'D:\Database\NJROS1D151DEV\MSSQL$NJROS1D151DEV\Dat a\TaxReconDB_Prod_Log.LDF'
, REPLACE

ALTER DATABASE TaxReconDB_Prod SET READ_WRITE

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Tuesday, February 14, 2012

converting SQL 2000 data into a SQL 2005 server

I have a large (huge) database that I want to copy onto my new slq 2005 test server. I'm leaning toward detaching the data on my 2000 box, duplicating it, copying it to my new 2005 machine, and attaching it. Is it possible that it could be that simple? If not, how is it done? Thanks a bunch for any help or pointers to the articles I was totally unable to find on the subject.
Yes, it should be that simple. Use sp_detach_db and sp_attach_db; check BOL for details if you need them.|||

Thanks Paul! I appreciate the confirmation that I was on the right track. I did stumble across and article I found useful at...

http://www.aspfree.com/c/a/MS-SQL-Server/Moving-Data-from-SQL-Server-2000-to-SQL-Server-2005/

Also, I had no idea where the sql server Management Studio was or how to install it. Finally I put in the sql server 2005 install cd, and chose client tools. It intalled and now I can use it to reattach the database.

Best wishes