MergeData

@echo off
title PubwinTool By 76449628
color 0A
if not exist "%java_home%\bin\java.exe" goto end2
:fir
cls
echo use local                              >test.sql
echo go                                     >test.sql
set /p pwd="请输入数据库访问密码:"
OSQL /S localhost /U netcafe /P %userpwd% /i test.sql
IF ERRORLEVEL 1 goto end1
del /f /q test.sql
cls
osql -U netcafe -P %pwd% -d local -Q "update local1.dbo.mem_localmemberbaseinfo set id=id+100000"
osql -U netcafe -P %pwd% -d local -Q "update local1.dbo.mem_localdiscountaccount set id=id+100000"
osql -U netcafe -P %pwd% -d local -Q "insert into local.dbo.mem_localmemberbaseinfo select * from local1.dbo.mem_localmemberbaseinfo"
osql -U netcafe -P %pwd% -d local -Q "insert into local.dbo.mem_localdiscountaccount select * from local1.dbo.mem_localdiscountaccount"
osql -U netcafe -P %pwd% -d local -Q "insert into local.dbo.leveltype select * from local1.dbo.leveltype"
osql -U netcafe -P %pwd% -d local -Q "create table merge_data (uniqueid varchar(20) not null,suma bigint not null)"
osql -U netcafe -P %pwd% -d local -Q "insert into merge_data select b,c from (select count(uniqueid) as a,uniqueid as b,sum(balance) as c from mem_localmemberbaseinfo group by uniqueid having count(uniqueid)>1) x"
osql -U netcafe -P %pwd% -d local -Q "select * from merge_data">c:\ddd.txt
for /f "skip=2" %%j in (c:\ddd.txt) do echo %%j>>c:\new.txt
for /f "eol=(" %%a in (c:\new.txt) do echo %%a>>c:\meminfo.txt
for /f "delims=" %%i in (c:\meminfo.txt) do (osql -U netcafe -P %pwd% -d local -Q "update mem_localmemberbaseinfo set balance=(select suma from merge_data where uniqueid='%%i') where uniqueid='%%i' and id>100000")
for /f "delims=" %%j in (c:\meminfo.txt) do (osql -U netcafe -P %pwd% -d local -Q "delete from mem_localmemberbaseinfo where uniqueid='%%j' and id<100000")
echo "数据库合并完成,请核对!"
pause

:end1
del /f /q test.sql
echo 数据库密码错误,请确认后再行尝试!
pause
goto fir

:end2
echo 本机不是PUBWIN服务端,请到PUBWIN服务端执行该脚本!
pause >nul

posted on 2013-12-25 16:55  awk  阅读(329)  评论(0)    收藏  举报

导航