1、备份 <% SQL="backup database 数据库名 to disk=''''"&Server.MapPath("backup")&"\"&"backuptext.dat"&"''''" set cnn=Server.createobject("adodb.connection") cnn.open "driver={SQL Server};Server=服务器名;uid=sa;pwd=" cnn.execute SQL on error resume next if err<>0 then response.write "错误:"&err.Descripting else response.write "数据备份成功!" end if %>
2、恢复 <% SQL="Restore database 数据库名 from disk=''''"&Server.MapPath("backup")&"\"&"backuptext.dat"&"''''" set cnn=Server.createobject("adodb.connection") cnn.open "driver={SQL Server};Server=服务器名;uid=sa;pwd=" cnn.execute SQL on error resume next if err<>0 then response.write "错误:"&err.Descripting else response.write "数据恢复成功!" end if %>
注:以上语句是把数据备份到磁盘的backup目录下,文件名为backuptext.dat。
2、ASP中能修改SQL数据库结构吗? 答:ALTER TABLE 名称 ALTER TABLE — 更改表属性 语法 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 Inputs table 试图更改的现存表的名称. column 现存或新的列名称. type 新列的类型. newcolumn 现存列的新名称. newtable 表的新名称. table constraint definition 表的新的约束定义.
SELECT NewColumn FROM SuperClass* 将不能工作,因为子表会比上级表少一个属性。 在目前的实现里,新列/字段的缺省(值)和约束子句会被忽略。你可以随后用 ALTER TABLE 的 SET DEFAULT 形式设置缺省(值)。(你还不得不用 UPDATE 把已存在行更新为缺省值。)