Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Duplication of DB
Message
From
12/04/2005 04:46:26
Jon Neale
Bond International Software
Wootton Bassett, United Kingdom
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01003617
Message ID:
01003620
Views:
22
You could backup the database and then restore (called something else) it by calling a stored procedure in SQL Server using SPT.

----------------------------------------
CREATE PROCEDURE resetdata
@dbname varchar(20),
@filename varchar(80)
AS

BACKUP DATABASE @dbname TO DISK = @filename
RESTORE DATABASE @dbname FROM DISK = @filename
----------------------------------------

To call it form VFP do something similar to below;
--------------------------------------------
lcConnectString = "driver=SQL Server;server=ISC34;uid=sa;pwd=jon;Database=master;app='';Encrypt='';"
lnConnectHandle = SQLSTRINGCONNECT(lcConnectString)

cDatabase = "PPWin"
cLocation = "c:\tmp\PPWin.Bak"

lnresult = Sqlexec(lnConnectHandle, [EXEC resetdata ?cDatabase, ?cLocation])
if lnresult < 0
messagebox("Error Occurred with restore")
else
messagebox("Restore Complete")
endif
----------------------------------------------

You will need to tweak this abit but I hope it gives you some idea.

>Hi to all,
>
>I need to duplicate an MS SQL DB.
>How can I perform this from VFP ?
>
>Thank you for reply.
>Gaetano
Previous
Reply
Map
View

Click here to load this message in the networking platform