Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Copy Database

Author  Topic 

kamalkishore_in
Yak Posting Veteran

76 Posts

Posted - 2002-11-05 : 04:40:49
hi,
I have to copy a database into one of Client System in my NETWORK(Just for sake of Backup). I can do it by setting up a backup plan.

But the requirement is like that, I have to copy DATAFILE (Both MDF and LDF) to that clients System, as it does not need to configure anything.

I am using VB6. I made a small programme for this task. It is copping the Datafile to the Clients System. But If any of the client is Connected to the DATABASE it is generating error.

May be this is not the correct approach to perform this task, or there might be some wayout for this situation.

I am using the following code

Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile PathFrom, PathTo, True

Any help would be heightly appriciated..
thankx

ashok
Yak Posting Veteran

57 Posts

Posted - 2002-11-05 : 06:44:18
The mdf and ldf are in use by SQL Server so you cannot do a file system level copy of the database files.

You could try and transfer the database to the client side by using SQL Backup (at your end) / Restore (at the client end) , this will work even when users are connected and you can automate it programmatically.

You can also take a look at DTS to transfer the whole database / or selected parts to the client pcs over the network.




-ashok
"Bad dancing does not break an engagement."

Go to Top of Page

kamalkishore_in
Yak Posting Veteran

76 Posts

Posted - 2002-11-05 : 07:29:08
Yes, I got it.

Does anybody know, how to Stop SQL Sever and Run it again, using VB. That might solve my problem. (I am aware of Truning SQL Server OFF/ON). But I have given permission for that.

Client does not have SQL server Installed.

Help needed

Go to Top of Page

kamalkishore_in
Yak Posting Veteran

76 Posts

Posted - 2002-11-12 : 02:41:56
Hi again,

May be it not a VB help website.

Okey is there any SP available which will copy the datafile to some location of my server, so that I can copy it from there to a client palce.

Hope for the solution this time
Thankx

Go to Top of Page

jeroena
Yak Posting Veteran

76 Posts

Posted - 2002-11-12 : 03:58:28
Hi,

This might help:

To move a database, or database file, to another server or disk:

1. Detach the database.
2. Move (or copy) the database file(s) to the other server or disk.
3. Attach the database specifying the new location of the moved file(s).

You can use sp_detach_db and sp_attach_db for this purpose.

Jeroen.

Go to Top of Page
   

- Advertisement -