Copying a database in SQL Server

Copying a database in SQL Server

Post by Paul » Thu, 12 Dec 2002 22:41:20



I have been asked to build a front end for a clients database in SQL Server.

What I was wondering is:

1) Can I somehow make a copy of the database so I can import it into the SQL
Server database I have in my office.

2) When I import a database into SQL Server I always lose the relationships.
Is it possible to import the relationships as well as the tables?

 
 
 

Copying a database in SQL Server

Post by Andrew J. Kell » Thu, 12 Dec 2002 23:08:22


See my reply in .server.    You can post to multiple NG's in a coordinated
fashion by just including the other NGs in the NewsGroups section of the
post.  That way when one is answered it shows up in all the posts at once.

--
Andrew J. Kelly
SQL Server MVP


Quote:> I have been asked to build a front end for a clients database in SQL
Server.

> What I was wondering is:

> 1) Can I somehow make a copy of the database so I can import it into the
SQL
> Server database I have in my office.

> 2) When I import a database into SQL Server I always lose the
relationships.
> Is it possible to import the relationships as well as the tables?


 
 
 

1. Copying a database from SQL Server 2k to SSCE

I want to make a copy of the database tables/structures etc - I created
these in Access (cos I'm familiar with it) and have successfully imported
them into a database on a remote SQL Server 2000, using DTS Import (part of
SQL2k Enterprise Manager).

I want these same tables in an SSCE SDF file on my local device. I have
found quite a few examples out there on how to do stuff roughly like this,
but they all seem to involve creating the tables on the device using a
series of SQL DDL statements.

I found in the help files some stuff on DataTable.Copy() and
DataTable.Clone() which I think should do exactly what I am looking for -
all I want at this stage is a simple copy of some of the tables in the
database for doing initial testing. Further down the road, we will set up
the replication, RDA sync etc.

So, I thought I should be able to open a connection to the remote SQL2k
server, open a connection to the local SSCE SDF file - found stuff on how to
do that so I think it's ok...
...then open a table on the connection to the SQL2k server and then use
Copy() or Clone() to clone the table to the local SDF.
But I can't quite figure out how to open a DataTable using a connection...I
don't see a command like

dim myTbl as DataTable
'How do I do the next line
myTbl = cn.Tables.open("FirstTable")

'then I should be able to ...

destinationDataTable = MyTbl.Clone()

BTW, can you have two connections open at once, to two different databases
(local OLEDB, remote SQL)?

All the examples I have seen so far involve using a DataSet, Fill() and
Update(), which is fine if the destination table exists...but with 10 tables
to create as a once off, I don't really want to create them using a series
of SQL statements.

There's gotta be an easier way! Hopefully...

2. Probably a silly question

3. COpy a database from Sql Server

4. Updating database without updating cursor on grid

5. How to copy a database from SQL Server into MSDE on Other PC?

6. Help with Web database project

7. Copying database from SQL server 2000 to remote SQL server 7.0

8. NEWBIE: DB Relationships

9. copying sql server 7 database to sql server 2000 w/ no remote access

10. SQL Server - Copy a table from one database to another database

11. Copying SQL Server Databases to a New SBS Server

12. Best way to copy SQL Server (databases) to another server