You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.6 KiB
94 lines
2.6 KiB
1 year ago
|
use main
|
||
|
|
||
|
CREATE TABLE #T
|
||
|
(
|
||
|
mch_no varchar(100)
|
||
|
)
|
||
|
|
||
|
INSERT #T SELECT '0471chaoyin'
|
||
|
INSERT #T SELECT '0359VEYIA'
|
||
|
INSERT #T SELECT '0471BaoGeLi'
|
||
|
INSERT #T SELECT '0359ZhenYe'
|
||
|
INSERT #T SELECT '0471DiSiYing'
|
||
|
INSERT #T SELECT '0319LSHY'
|
||
|
INSERT #T SELECT '0319PLJZ'
|
||
|
INSERT #T SELECT '0310Liang'
|
||
|
INSERT #T SELECT '0358JiangRen'
|
||
|
INSERT #T SELECT '0357xinchiye'
|
||
|
INSERT #T SELECT '0352GuJu'
|
||
|
INSERT #T SELECT '0358FaCaiXuan'
|
||
|
INSERT #T SELECT '0359BaSha'
|
||
|
INSERT #T SELECT '0471GuLi'
|
||
|
INSERT #T SELECT '0471MoBen'
|
||
|
INSERT #T SELECT '0353sfmy'
|
||
|
INSERT #T SELECT '0353XGYR'
|
||
|
INSERT #T SELECT '0351JianDan'
|
||
|
INSERT #T SELECT '0351BaHao'
|
||
|
INSERT #T SELECT '0351HuangFu'
|
||
|
INSERT #T SELECT '0358SiYi'
|
||
|
INSERT #T SELECT '0350HQMFSJ'
|
||
|
INSERT #T SELECT '0355Mu'
|
||
|
INSERT #T SELECT '0353ShangPin'
|
||
|
INSERT #T SELECT '0471ManHe'
|
||
|
INSERT #T SELECT '031021'
|
||
|
INSERT #T SELECT '0351tianmei'
|
||
|
INSERT #T SELECT '0393MeiKeSi'
|
||
|
INSERT #T SELECT '0310YNQSF'
|
||
|
INSERT #T SELECT '0315TFLL'
|
||
|
INSERT #T SELECT '0393TFLL'
|
||
|
INSERT #T SELECT '0393MLRS'
|
||
|
INSERT #T SELECT '0351HuangFu'
|
||
|
INSERT #T SELECT '0335ShouLing'
|
||
|
INSERT #T SELECT '0349ChuXin'
|
||
|
INSERT #T SELECT '0349ShenMei'
|
||
|
INSERT #T SELECT '0355TaTa'
|
||
|
INSERT #T SELECT '0354Sen'
|
||
|
INSERT #T SELECT '0354TaYa'
|
||
|
INSERT #T SELECT '0354TTV'
|
||
|
INSERT #T SELECT '0354ShenMei'
|
||
|
INSERT #T SELECT '0354NiuNiu'
|
||
|
INSERT #T SELECT '022NanFeng'
|
||
|
INSERT #T SELECT '0354YZR'
|
||
|
INSERT #T SELECT '0474MSMJ'
|
||
|
INSERT #T SELECT '0352SuiYuan'
|
||
|
INSERT #T SELECT '024zone'
|
||
|
INSERT #T SELECT '0353MeiShu'
|
||
|
INSERT #T SELECT '0353N3'
|
||
|
|
||
|
UPDATE TMerchantInfo SET FServerId = 773 WHERE FmchNo IN(SELECT mch_no FROM #T)
|
||
|
|
||
|
SELECT * FROM
|
||
|
|
||
|
drop table #db
|
||
|
|
||
|
|
||
|
--获取数据库名称
|
||
|
SELECT T.mch_no, LEFT(REPLACE(FConnectionString,'Data Source=(local);Initial Catalog=',''),CHARINDEX(';',REPLACE(FConnectionString,'Data Source=(local);Initial Catalog=',''))-1) as database_name
|
||
|
INTO #DB
|
||
|
FROM TMerchantServerConfig AS A,TMerchantInfo AS B,#T AS T
|
||
|
WHERE T.mch_no = B.FMchNo
|
||
|
AND A.FMchId = B.FMchId
|
||
|
|
||
|
--附加数据库
|
||
|
SELECT 'EXEC sp_attach_db @dbname=N''' + database_name + ''',@filename1=N''E:\SaiDao_Data\'+ database_name +'\'+ database_name+'.mdf'',@filename2=N''E:\SaiDao_Data\'+database_name+'\'+database_name+'_log.ldf'''
|
||
|
FROM #DB
|
||
|
|
||
|
--拷贝数据库日志
|
||
|
SELECT 'xcopy E:\AppServer\Log\Sql\'+database_name + ' F:\log\' + database_name + '\ /S /E /D /Y'
|
||
|
FROM #DB
|
||
|
|
||
|
--修改日志名称
|
||
|
SELECT 'rename E:\AppServer\Log\Sql\'+database_name + ' _moved_' + database_name
|
||
|
FROM #DB
|
||
|
|
||
|
SELECT mch_No FROM #T
|
||
|
GROUP BY mch_no
|
||
|
having sum(1) > 1
|
||
|
|
||
|
|
||
|
SELECT * FROM #DB
|
||
|
WHERE database_name = 'LinFen_HongXiaoYe_fenli'
|
||
|
|
||
|
delete #db where mch_no = '0357xinchiye'
|
||
|
delete #t where mch_no ='0357xinchiye'
|
||
|
|