网狐6.6.1升级编程手册(2012版)
wanghu065@gmail
1 数据库使用SQL Server2008 Express
windowsserver2012四个版本如果附加数据库时,提示数据库没有访问权限。只要将数据库文件和日志文件的user权限改为完全控制即可。
编写批处理文件attachDB.bat将数据库目录中的所有数据库加载到SQL Server2008 Express。
attachDB.bat:
SQLCMD -S ".\SQLEXPRESS" -U sa -P 123456 -i "Attach.sql" SQLCMD -S ".\SQLEXPRESS" -U sa -P 123456 -i "用户链接.sql" Attach.sql:
EXEC sp_attach_db @dbname = N'CxGameTreasuredb', @filename1 = N'D:\QP\DB\CxGameTreasuredb.mdf',
@filename2 = N'D:\QP\DB\CxGameTreasuredb_1.ldf'; EXEC sp_attach_db @dbname = N'KYGameDB',
@filename1 = N'D:\QP\DB\KYGameDB.mdf',
@filename2 = N'D:\QP\DB\KYGameDB_log.ldf';
EXEC sp_attach_db @dbname = N'News',
@filename1 = N'D:\QP\DB\News.mdf',
@filename2 = N'D:\QP\DB\News_1.ldf';
EXEC sp_attach_db @dbname = N'QPBilliardsDB',
@filename1 = N'D:\QP\DB\QPBilliardsDB.mdf',
@filename2 = N'D:\QP\DB\QPBilliardsDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPcdmjDB',
@filename1 = N'D:\QP\DB\QPcdmjDB.mdf',
@filename2 = N'D:\QP\DB\QPcdmjDB_log.ldf';
EXEC sp_attach_db @dbname = N'QPChessDB',
@filename1 = N'D:\QP\DB\QPChessDB.mdf',
@filename2 = N'D:\QP\DB\QPChessDB_log.ldf';
EXEC sp_attach_db @dbname = N'QPChinaChessDB', @filename1 = N'D:\QP\DB\QPChinaChessDB.mdf',
@filename2 = N'D:\QP\DB\QPChinaChessDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPGameScoreDB', @filename1 = N'D:\QP\DB\QPGameScoreDB.mdf',
@filename2 = N'D:\QP\DB\QPGameScoreDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPGameUserDB', @filename1 = N'D:\QP\DB\QPGameUserDB.mdf',
@filename2 = N'D:\QP\DB\QPGameUserDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPGoBangDB',
@filename1 = N'D:\QP\DB\QPGoBangDB.mdf',
@filename2 = N'D:\QP\DB\QPGoBangDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPGuanPaiDB',
@filename1 = N'D:\QP\DB\QPGuanPaiDB.mdf',
@filename2 = N'D:\QP\DB\QPGuanPaiDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPLandDB',
@filename1 = N'D:\QP\DB\QPLandDB.mdf',
@filename2 = N'D:\QP\DB\QPLandDB_log.ldf';
EXEC sp_attach_db @dbname = N'QPLandCrazyDB', @filename1 = N'D:\QP\DB\QPLandCrazyDB.mdf',
@filename2 = N'D:\QP\DB\QPLandCrazyDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPLandEXVDDB', @filename1 = N'D:\QP\DB\QPLandEXVDDB.mdf',
@filename2 = N'D:\QP\DB\QPLandEXVDDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPLandSCDB',
@filename1 = N'D:\QP\DB\QPLandSCDB.mdf',
@filename2 = N'D:\QP\DB\QPLandSCDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPLandVDDB',
@filename1 = N'D:\QP\DB\QPLandVDDB.mdf',
@filename2 = N'D:\QP\DB\QPLandVDDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPLLShowDB',
@filename1 = N'D:\QP\DB\QPLLShowDB.mdf',
@filename2 = N'D:\QP\DB\QPLLShowDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPServerInfoDB', @filename1 = N'D:\QP\DB\QPServerInfoDB.mdf',
@filename2 = N'D:\QP\DB\QPServerInfoDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPShuangKouBBDB', @filename1 = N'D:\QP\DB\QPShuangKouBBDB.mdf',
@filename2 = N'D:\QP\DB\QPShuangKouBBDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPShuangKouDB', @filename1 = N'D:\QP\DB\QPShuangKouDB.mdf',
@filename2 = N'D:\QP\DB\QPShuangKouDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPSparrowDZDB', @filename1 = N'D:\QP\DB\QPSparrowDZDB.mdf',
@filename2 = N'D:\QP\DB\QPSparrowDZDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPTreasureDB',
@filename1 = N'D:\QP\DB\QPTreasureDB.mdf',
@filename2 = N'D:\QP\DB\QPTreasureDB_log.ldf'; EXEC sp_attach_db @dbname = N'QPUpGradeDB',
@filename1 = N'D:\QP\DB\QPUpGradeDB.mdf',
@filename2 = N'D:\QP\DB\QPUpGradeDB_log.ldf';
EXEC sp_attach_db @dbname = N'QPWeiQiDB',
@filename1 = N'D:\QP\DB\QPWeiQiDB.mdf',
@filename2 = N'D:\QP\DB\QPWeiQiDB_log.ldf';
EXEC sp_attach_db @dbname = N'WHPaoHuZiDB',
@filename1 = N'D:\QP\DB\WHPaoHuZiDB.mdf',
@filename2 = N'D:\QP\DB\WHPaoHuZiDB_log.ldf';
EXEC sp_attach_db @dbname = N'WHSanDaYiDB',
@filename1 = N'D:\QP\DB\WHSanDaYiDB.mdf',
@filename2 = N'D:\QP\DB\WHSanDaYiDB_log.ldf';
EXEC sp_attach_db @dbname = N'WHThreasureDB',
@filename1 = N'D:\QP\DB\WHThreasureDB.mdf',
@filename2 = N'D:\QP\DB\WHThreasureDB_log.ldf';
用户链接.sql
-- 变量定义
DECLARE @DBName VARCHAR(32)
DECLARE @DBUser VARCHAR(32)
DECLARE @DBPassword VARCHAR(32)
DECLARE @DBSourceAddr VARCHAR(32)
DECLARE @LinkServerName VARCHAR(32)
-- 设置变量
SET @LinkServerName='QPGameUserDBLink'
SET @DBSourceAddr='.\SQLEXPRESS'
SET @DBName='QPGameUserDB'
-- 删除连接服务器
IF EXISTS(SELECT SrvName FROM MASTER.DBO.SYSSERVERS WHERE SrvName=@LinkServerName)
BEGIN
EXEC SP_DROPSERVER @LinkServerName,'DropLogins'
END
-- 建立链接服务器
EXEC SP_ADDLINKEDSERVER
@Server=@LinkServerName,
@SrvProduct=@LinkServerName,
@Provider='SQLOLEDB',
@DataSrc=@DBSourceAddr,
@Location='',
@ProvStr='',
@Catalog=@DBName
-- 用户映射
EXEC SP_ADDLINKEDSRVLOGIN @RmtSrvName=@LinkServerName,@Useself='true',@LocalLogin=NULL,@RmtUser=NULL,@Rmt Password=NULL
-- 设置链接服务器
EXEC SP_SERVEROPTION @Server=@LinkServerName,@OptName='RPC',@OptValue='true' EXEC SP_SERVEROPTION @Server=@LinkServerName,@OptName='RPC OUT',@OptValue='true' EXEC SP_SERVEROPTION @Server=@LinkServerName,@OptName='Data Access',@OptValue='true'
EXEC SP_SERVEROPTION @Server=@LinkServerName,@OptName='Collation CompaTible',@OptValue='true'
EXEC SP_SERVEROPTION @Server=@LinkServerName,@OptName='Use Remote Collation',@OptValue='true'
-- 链接服务器状态
EXEC SP_HELPSERVER @LinkServerName
编写批处理文件detachDB.bat SQL Server2008 Express中的所有数据卸载。如果数据库正在被使用,请重启SQL Server2008服务
detachDB.bat
SQLCMD -S ".\SQLEXPRESS" -U sa -P 123456 -i "Detach.sql"
Detach.sql
EXEC sp_detach_db 'KYGameDB', 'true';
EXEC sp_detach_db 'CxGameTreasuredb', 'true';
EXEC sp_detach_db 'News', 'true';
EXEC sp_detach_db 'QPBilliardsDB', 'true';
EXEC sp_detach_db 'QPcdmjDB', 'true';
EXEC sp_detach_db 'QPChessDB', 'true';
EXEC sp_detach_db 'QPChinaChessDB', 'true';
EXEC sp_detach_db 'QPGameScoreDB', 'true';
EXEC sp_detach_db 'QPGameUserDB', 'true';
EXEC sp_detach_db 'QPGoBangDB', 'true';
EXEC sp_detach_db 'QPGuanPaiDB', 'true';
EXEC sp_detach_db 'QPLandCrazyDB', 'true';
EXEC sp_detach_db 'QPLandDB', 'true';
EXEC sp_detach_db 'QPLandEXVDDB', 'true';
EXEC sp_detach_db 'QPLandSCDB', 'true';
EXEC sp_detach_db 'QPLandVDDB', 'true';
EXEC sp_detach_db 'QPLLShowDB', 'true';
EXEC sp_detach_db 'QPServerInfoDB', 'true';
EXEC sp_detach_db 'QPShuangKouBBDB', 'true';
EXEC sp_detach_db 'QPShuangKouDB', 'true';
EXEC sp_detach_db 'QPSparrowDZDB', 'true';
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论