Backup database to disk backup Database testdb to disk = 'e: /msql/backup/testdb.bak'
Backup diary to disk backup log master to disk = 'e: /msql/backup/testdb.tn'
View file information in the backup Restore FileListonly from disk = 'e: /msql/backup/testdb.bak'
Restore from backup to a new database restore database testdb_new from disk = 'e: /msql/backup/testdb.bak' with move testdb_data 'to' E: /MSSQL/Data/mssql/data/testdb_new.mdf ', Move' TESTDB_LOG 'to' E: /MSSQL/Data/msql/data/testdb_new.ldf '
View system stored procedure Select * from master..sysobjects where name like 'sp_%'
Export query results to Excelexec XP_cmdshell 'OSQL / S MusqlServer / U SA / P mypwd / d testdb / q "SELECT TOP 10 * from testable" / o c: /my1.xls "
Full Backup Pubs Database / * Create Backup Device * / Use Masterexec SP_ADDUMPDEVICE 'DISK' 'PUBSS' '' C: /MSSQL7/backup/pubss.dat '/ * Backup Database * / Backup Database Pubs To Pubss / * Create Transaction Log Backup Device * /. USE MASTEREXEC SP_ADDUMPDEVICE 'DISK' 'Pubsslog' 'C: /Mssql7/backup/pubsslog.dat' / * Backup Transaction Log * / Backup Log Pubs To Pubsslog Restore Database Pubs to April 1 April 2000 RESTORE DATABASE Pubsfrom Pubss1 Pubss2with NorecoveryRestore log Pubsfrom Pubsslog1with NorecoveryRestore log pubsfrom pubslog2with recovery stopat = 'Apr 1 2000 15:00 AM'
Related resources: Flow control statements commonly used in SQLServer