SQL backup and recovery using asp

Source: Internet
Author: User
1. Backup
<%
SQL = "backup database name to disk = '" & Server. MapPath ("backup") & "&" backuptext. dat "&"'"
Set cnn = Server. createobject ("adodb. connection ")
Cnn. open "driver = {SQL Server}; Server = Server Name; uid = sa; pwd ="
Cnn.exe cute SQL
On error resume next
If err <> 0 then
Response. write "error:" & err. Descripting
Else
Response. write "data backup successful! "
End if
%>
2. Recovery
<%
SQL = "Restore database name from disk = '" & Server. MapPath ("backup") & "&" backuptext. dat "&"'"
Set cnn = Server. createobject ("adodb. connection ")
Cnn. open "driver = {SQL Server}; Server = Server Name; uid = sa; pwd ="
Cnn.exe cute SQL
On error resume next
If err <> 0 then
Response. write "error:" & err. Descripting
Else
Response. write "data recovery successful! "
End if
%>
Note: the preceding statement backs up data to the backup directory of the disk. The file name is backuptext. dat.
2. Can I modify the SQL database structure in ASP?
A: ALTER TABLE
Name
Alter table-modify TABLE attributes
Syntax
Alter table table [*]
ADD [COLUMN] column type
Alter table table [*]
ALTER [COLUMN] column {set default value | drop default}
Alter table table [*]
RENAME [COLUMN] column TO newcolumn
Alter table table
Rename to newtable
Alter table table
ADD table constraint definition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.