数据库操作技巧

//读出设备名字
restore FILELISTONLY  from disk='D:\temp\databak'

//还原数据库
restore database singlepos from disk='D:\temp\databak'
with move 'CHAIN_OL_DEV_Data' to 'E:\dev\single_data.mdf',
     move 'CHAIN_OL_DEV_Log' to 'E:\dev\single_log.ldf'


--读出日志和数据文件
RESTORE FILELISTONLY from disk='d:\lqbh.bak'
--还原数据库
restore database zybh from disk='d:\lqbh.bak'
with move 'thbh_Data' to 'd:\MSSQL\zybh_data.mdf',
     move 'thbh_Log' to 'd:\MSSQL\zybh_log.ldf',
 move 'lqbh_1_Log' to 'd:\MSSQL\zybh_log_1.ldf'




 

execute xp_shell 'nd d:\db'//新建文件夹


//其他技巧
//创建数据库
create database jtms
on primary (name='jtms_data',filename='F:\svn\工具\进销存\db\jtms_data.mdf')
log on (name='jtms_log',filename='F:\svn\工具\进销存\db\jtms_log.ldf')
//还原数据库
restore database jtms from disk='F:\svn\工具\进销存\db\JTMS_2007-6-25'

use master
//分离数据库
execute sp_detach_db jtms
//附加数据库
execute sp_attach_db 'jtms','F:\svn\工具\进销存\db\jtms_data.mdf','F:\svn\工具\进销存\db\jtms_log.ldf'

 

 

 

 

 

你可能感兴趣的:(SVN,XP,F#)