Eli,
If you wanted to Use ASP, instead of trying to do a restore, (which I
don't think you will have much success with by using ASP) use an SQL
delete statement and delete the table. Then, using a text file, with the
information in it, create a new table and import the information using the
FileSystemObject. However, the best way to do this would be to use SQL
Server and set up a job to do the restore each night. You could do this by
using the SQL Server Agent or by using the DTS tools in SQL Server. Using
ASP is going to be much more difficult. I have found it very easy to do
these type of actions with the DTS. What you would want to do is to save
the table information into a text file. Then each night you could have a
DTS set up that deletes the existing table and then imports the
information from the text file into a recreated table with the original
information. All of this can be set up using GUI's in Enterprise Manager,
which will save time rather than writing a long ASP to accomplish the same
thindg. I have some jobs set up this way that work nicely. Hope this
helps.
Mike.
> I'm currently trying to setup a page that does an automatic SQL restore
> using a file that gets dumped onto the SQL server every night.
Currently I
> have:
>
> set conn = server.CreateObject("ADODB.connection")
> conn.Open "Provider=SQLOLEDB.1;Driver={SQL
> Server};Server=servername;Database=MyTest;UID=User;PWD=password"
>
> SQL = "Restore Database MyTest from Disk='c:\mytest.bk' with
> Recovery"
>
> Set RS=Conn.execute(SQL)
>
> Conn.close
>
> When I execute this script I get:
>
> Error Type:
> Microsoft OLE DB Provider for SQL Server (0x80040E14)
> Database in use. The system administrator must have exclusive use of the
> database to run the restore operation.
> /sqlrestore.asp, line 11
>
> However, I have nothing open in the DB and no one is connected to it.
If I
> run this same script in query analyzer it executes but then the database
> shows as "Loading" until I do a manual restore through Enterprise
Manager.
>
> Is there a better script for restoring or am I doing something wrong
here?
>
> Thanks,
> Eli