1. Backup
<%
SQL="backupdatabase database name todisk='"&Server.MapPath("backup")&"/"&"backuptext.dat"&"'"
setcnn=Server.createobject("adodb.connection")
cnn.open"driver={SQLServer};Server=server name;uid=sa;pwd="
cnn.executeSQL
onerrorresumenext
iferr<>0then
response.write"Error:"&err.Descripting
else
response.write "Data backup was successful!"
endif
%>
2. Recovery
<%
SQL="Restoredatabase database name fromdisk='"&Server.MapPath("backup")&"/"&"backuptext.dat"&"'"
setcnn=Server.createobject("adodb.connection")
cnn.open"driver={SQLServer};Server=server name;uid=sa;pwd="
cnn.executeSQL
onerrorresumenext
iferr<>0then
response.write"Error:"&err.Descripting
else
response.write "Data recovery succeeded!"
endif
%>
Note: The above statement is to back up the data to the backup directory of the disk, and the file name is backuptext.dat.
2. Can SQL database structure be modified in ASP?
Answer: ALTERTABLE
name
ALTERTABLE—Change table properties
grammar
ALTERTABLEtable[*]
ADD[COLUMN]columntype
ALTERTABLEtable[*]
ALTER[COLUMN]column{SETDEFAULTvalueDROPDEFAULT}
ALTERTABLEtable[*]
RENAME[COLUMN]columnTOnewcolumn
ALTERTABLEtable
RENAMETOnewtable
ALTERTABLEtable
ADDtableconstraintdefinition
Inputs
table
The name of the existing table that is attempting to change.
column
Existing or new column name.
type
Type of new column.
newcolumn
New name of the existing column.
newtable
The new name of the table.
tableconstraintdefinition
New constraint definition for tables.
Newtableconstraintforthetable
Output
ALTER
Information returned from the renamed column or table.
ERROR
If a column or table does not exist, the returned information is returned.
describe
ALTERTABLE changes the definition of an existing table. The ADDCOLUMN form adds a new column/field to the table with the same syntax as CREATETABLE. The ALTERCOLUMN form allows you to set or delete defaults (values) from columns/fields. Note that the default (value) is only valid for newly inserted rows. The RENAME clause can change the name of a table or column/field without affecting any data in the relevant table. Therefore, the table or column/field will still be of the same size and type after this command is executed. The ADDtableconstraintdefinition clause adds a new constraint to the table with the same syntax as CREATETABLE.