Showing posts with label named. Show all posts
Showing posts with label named. Show all posts

Tuesday, March 20, 2012

Copy database to same server but with a different name

I have a production database named "PRODUCTION_DATABASE" on "SERVER1". I would like to copy this database (and all its views, stored procedures, etc.) to the same server but under a different database name (i.e., "TEST_DATABASE" on "SERVER1"). This copy will be used for software development testing purposes.

What is the best way to do this?

P.S. I have SQL Server 2000 Enterprise Edition.You can use DTS to copy the database, or you can use a backup file from the production database and restore it to the test database. to use DTS, right click on the database, select Export, then when given the chance, Export Objects. When selecting a destination database, select New and you will be able to create the new database.|||douglas.reilly,

Your DTS suggestion worked perfectly! Thanks :)

Wednesday, March 7, 2012

Copy a table from one DB to another DB

HI All,

i have 2 databases x and y

a table in x named as table1

i am looking to copy 'table1' from database x to database y say named 'table2'

Database y doesnt have a table1

Version: SQL Server 2000

How to do this on Query Analyzer and/or Enterprise Manager?

Thanksuse this if table 2 does not exist in y.

select column1,column2
into y.dbo.table2
from x.dbo.table1

if table 2 does exist, use this...

INSERT INTO y.dbo.table2(column1,column2)
SELECT column1,column2
FROM x.dbo.table1|||Generate create table script and run it on y database then use import / export utility to transfer data.

SQL queries posted by Thrasymachus will also create new table and transfer data but if you need table dependent objects like triggers, constraints or indexes on your second database also, this way is useless.|||also, if you are copying millions of rows, better to use bcp with the -b flag.

otherwise your tlog will bloat.

Friday, February 24, 2012

Copied database maintains original name in backups

I made a copy of a database "sac_prod" and named the new copy "vgs_prod". Now, when I do a backup of the new database, it still shows the name of the original. Is there any way to change this so it will be the same as the new database name?
Here is the BACKUP script:
BACKUPdatabase vgs_prod TODISK=
'\\sac-srvr1\data$\Technical\Shared\Production\SQLBackup\ LasVegas\vgs_prod_CopyOnly.BAK'
with COPY_ONLY
Here is the messages I received from this BACKUP:
Processed 1752 pages for database 'vgs_prod', file 'sac_prod' on file 1.
Processed 6 pages for database 'vgs_prod', file 'sac_prod_log' on file 1.
BACKUP DATABASE successfully processed 1758 pages in 0.412 seconds (34.955 MB/sec).

I would like to change the file 'sac_prod' to be 'vgs_prod' in lines 1 and 2 just above.

Thanks,it is the logical file name being displayed. it should not create any problem anywhere. still if u want to change

alter database vgs_prod modify file (NAME = 'sac_prod' , NEWNAME = 'vgs_prod')|||Thank you. I will be working with this later today.