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.
sql-tools/temp/使用的卡也可以删除的问题.sql

762 lines
15 KiB

1 year ago
declare @index int
select @index = 1;
goto BeginTask
RunTask:
--print db_name()
---------------------------------------------
if(db_name() not in ('','','','',''))
begin
print db_name()
IF NOT EXISTS(SELECT 1 FROM TMemberCard WHERE FCardId = 0)
begin
INSERT INTO TMemberCard(FCardId,FCardNo,FCardFaceNo,FTypeId,FValueType,FCompId,FMemId,FState,FCreateDate,FExpiredDate,FTotalTimes,FUsedTimes,FMemo,FSaleCompId)
VALUES (0,'ɢ<EFBFBD><EFBFBD>','ɢ<EFBFBD><EFBFBD>',0,1,0,0,0,'1753-01-01','9999-12-31',0,0,'',0)
end
IF NOT EXISTS(SELECT 1 FROM TMemberCardType WHERE FId = 0)
begin
INSERT TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
VALUES (0,'ɢ<EFBFBD><EFBFBD>','ɢ<EFBFBD><EFBFBD>',1,1,0,0,0,0,0,0,0,0,0,0,0,0,'9999-12-31','',1,2147483647,0,0,0,0)
END
IF NOT EXISTS (SELECT 1
FROM dbo.sysreferences r
JOIN dbo.sysobjects o
ON (o.id = r.constid AND o.type = 'F')
WHERE r.fkeyid = object_id('TConsumeBill')
AND o.name = 'FK_CONSUME_BILL_CARD_ID')
BEGIN
ALTER TABLE TConsumeBill
ADD CONSTRAINT FK_CONSUME_BILL_CARD_ID FOREIGN KEY (FCardId)
REFERENCES TMemberCard (FCardId)
END
end
--SELECT * FROM sysobjects WHERE name = 'FK_CONSUME_BILL_MEM_ID'
--ALTER TABLE TConsumeBill DROP CONSTRAINT FK_CONSUME_BILL_MEM_ID
/*
INSERT INTO TMemberCard(FCardId,FCardNo,FCardFaceNo,FTypeId,FValueType,FCompId,FMemId,FState,FCreateDate,FExpiredDate,FTotalTimes,FUsedTimes,FMemo,FSaleCompId)
VALUES (0,'ɢ<EFBFBD><EFBFBD>','ɢ<EFBFBD><EFBFBD>',0,1,0,0,0,'1753-01-01','9999-12-31',0,0,'',0)
INSERT TMember(FMemId,FMemNo,FName,FCompId,FTypeId,FCreateDate,FGender,FBirthdayType,FBirthday,FTelephone,FMobilePhone,FQQ,FWeChat,FIdCard,FEmail,FAddress,FProId,FChargeEmpId,FPoint,FRecvConsSMS,FRecvBulkSMS,FMemo,FCPW,FQPW)
VALUES (0,'ɢ<EFBFBD><EFBFBD>','ɢ<EFBFBD><EFBFBD>',1,0,'1753-01-01',0,1,0,'','','','','','','',0,0,0,0,0,'','','')
USE TaiYuan_TouFaChangLe
GO
SELECT FPW FROM TUser WHERE FId = 1
SEL ECT * FROM TGoods
UPDATE TGoods SET FEnabled = 1
INSERT AppServer..TErrorDeletedMember(FDatabase,FBillId,FMemId)
SELECT db_name(),FBillId,FMemId FROM TConsumeBill WHERE FMemId NOT IN(SELECT FMemId FROM TMember)
SELECT * FROM AppServer..TErrorDeletedMember WHERE FBillId = 5522309171963565369
SELECT dbo.FNCompNo(FCompId), * FROM TConsumeBill WHERE FMemId NOT IN(SELECT FMemId FROM TMember)
SELECT * FROM TMemberCard WHERE FCardId = 7802496684783142429
SELECT * FROM TMemberCardAccount WHERE FCardId = 7802496684783142429
SELECT * FROM TMemberCardAcctHist WHERE FCardId = 7802496684783142429
DELETE TMemberCardAcctHist WHERE FCardId = 7802496684783142429
DELETE TMemberTransHist WHERE FCardId = 7802496684783142429
SELECT dbo.FNCompNo(FCompId), * FROM TConsumeBill WHERE FCardId NOT IN(SELECT FCardId FROM TMemberCard)
UPDATE TConsumeBill SET FCardId = 0 WHERE FBillId = 5257986286921771084
SELECT * FROM JiNan_XiuMuMing..TOrderBill
ORDER BY CONVERT(varchar(100), FBillTime, 8)
WHERE FBillTime
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
EXEC PRecalcCardAccHistBalance 5417523925839600429,NULL,NULL
--<EFBFBD>ѻ<EFBFBD>ԱID<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0
UPDATE TConsumeBill SET FMemId = FMemId ,FCardId = 0 WHERE FBillId = 4728606022837622119
DELETE TMemberCardAcctHist WHERE FTransId = 4728606022837622119
UPDATE TConsumeBill SET FMemId = 0 ,FCardId = 0 WHERE FMemId NOT IN(SELECT FMemId FROM TMember)
AND FState = 3
UPDATE TConsumeBill SET FMemId = 0 ,FCardId = 0 WHERE FCardId NOT IN(SELECT FCardId FROM TMemberCard)
AND FState = 3
UPDATE TConsumeBill SET FCardId = 0,FCardNo = '' WHERE FBillId = 5465421907128436028
UPDATE TConsumeItemPayment SET FPayTypeId = 1 WHERE FBillId = 5465421907128436028
SELECT * FROM TConsumeBill WHERE FState = 3
SELECT * FROM TBizLog WHERE FContent LIKE '%5277089550313897538%'
DELETE TMemberTransHist WHERE FMemId = 5044025498692615057
DELETE TMemberCardAcctHist WHERE FMemId = 5044025498692615057
SELECT * FROM TMemberCardAccount WHERE FMemId = 4858140492829427742
SELECT * FROM TMemberTransHist WHERE FMemId = 4780477039600228876
SELECT * FROM TMemberCardAcctHist WHERE FMemId = 4780477039600228876
SELECT * FROM TMemberCourse WHERE FMemId = 4780477039600228876
SELECT * FROM TMemberCourseHist WHERE FMemId = 4780477039600228876
DELETE
SELECT * FROM TMemberCard WHERE FCardId = 5604509277872010629
UPDATE TMemberTransHist SET FMemId = 5118720005888962936 WHERE FMemId = 4780477039600228876
UPDATE TMemberCardAcctHist SET FMemId = 5118720005888962936 WHERE FMemId = 4780477039600228876
UPDATE TMemberCourseHist SET FMemId = 5666763344808533906 WHERE FMemId = 5759803965966497825
UPDATE TConsumeBill SET FMemId = 4738297686044424811 WHERE FMemId = 5651560822119460120
UPDATE TMemberCourse SET FUsedPurTimes = 2 WHERE FMemId = 4738297686044424811
SELECT * FROM TMember WHERE FMemNo = '15954209753'
SELECT * FROM TBizLog WHERE FContent LIKE '%30174%'
SELECT * FROM TMember WHERE FMemId = 5118720005888962936
DECLARE @BillId BIGINT
SELECT @BillId = 4936645408302491547
UPDATE A
SET A.FMemId = B.FMemId
FROM TConsumeBill AS A,TMember AS B
WHERE A.FMemNo = B.FMemNo
AND A.FBillId = @BillId
UPDATE A
SET A.FCardId = B.FCardId
FROM TConsumeBill AS A,TMemberCard AS B
WHERE A.FCardNo = B.FCardNo
AND A.FBillId = @BillId
UPDATE B
SET B.FMemId = A.FMemId,
B.FCardId = A.FCardId
FROM TMemberTransHist AS B, TConsumeBill AS A
WHERE A.FBillID = B.FTransId
AND A.FBillId = @BillId
UPDATE B
SET B.FMemId = A.FMemId,
B.FCardId = A.FCardId
FROM TMemberCardAcctHist AS B, TConsumeBill AS A
WHERE A.FBillID = B.FTransId
AND A.FBillId = @BillId
UPDATE B
SET B.FMemId = A.FMemId
FROM TMemberCourseHist AS B, TConsumeBill AS A
WHERE A.FBillID = B.FTransId
AND A.FBillId = @BillId
UPDATE A
SET A.FMemCourseId = B.FId
FROM TConsumeBill AS T,TConsumeItem AS A,TMemberCourse AS B
WHERE A.FBillId = T.FBillId
AND T.FMemId = B.FMemId
AND T.FBillId = @BillId
AND A.FItemId = B.FItemId
SELECT * FROM TConsumeBill WHERE FBillId = 5706305102802533177
UPDATE TMemberCourse SET FUsedPurTimes = FUsedPurTimes + 1 WHERE FMemid = 4624510583738899783
UPDATE TConsumeBill SET FAuditTime =FBillTime WHERE FBillId = 5464001937057214438
UPDATE TMemberCardAccount SET FBalance= 475 WHERE FCardID = 5566091169087890147 AND FAcctId != 3
UPDATE TConsumeBill SET FState = 0 WHERE FBillId = 4676783228073637818
SELECT * FROM TConsumeBill WHERE FBillId = 5464001937057214438
SELECT * FROM TConsumeBill WHERE FBillNo = '1032725'
PAuditConsumeBill 5360082987278699409,1,5163807818120436790
SELECT * FROM TBizLog WHERE FUserNo = 'ADMIN'
DELETE TBizLog WHERE FId = 6901
SELECT * FROM TMember WHERE FMemNo = '003'
SELECT * FROM TMemberTransHist WHERE FMemId = 5154250830000611835
SELECT * FROM TMember WHERE FMemId = 5154250830000611835
SELECT * FROM TConsumeBill WHERE FBillId in(SELECT FMemId FROM AppServer..TErrorDeletedMember)
5526427960189495132
SELECT * FROM TMemberCourse WHERE FMemId = 5479556063884701434
DELETE TConsumeItemPayment WHERE FBillId = 4807835335665689289
DELETE TConsumeGoodsPayment WHERE FBillId = 4807835335665689289
DELETE TConsumeItemEmployee WHERE FBillId = 4807835335665689289
DELETE TConsumeGoodsEmployee WHERE FBillId = 4807835335665689289
DELETE TConsumeItem WHERE FBillId = 4807835335665689289
DELETE TConsumeGoods WHERE FBillId = 4807835335665689289
DELETE TConsumeBill WHERE FBillId = 4807835335665689289
-- SELECT * FROM TMember WHERE FMemNo = '9001'
*/
---------------------------------------------
SELECT @index = @index + 1
BeginTask:
IF @Index = 1
BEGIN
use BaoTou_MeiJueShi
goto RunTask
END
ELSE IF @Index = 2
BEGIN
use ChangSha_Demo1
goto RunTask
END
ELSE IF @Index = 3
BEGIN
use DongYing_ANan
goto RunTask
END
ELSE IF @Index = 4
BEGIN
use DongYing_DongHua
goto RunTask
END
ELSE IF @Index = 5
BEGIN
use DongYing_JiangRenWuQu
goto RunTask
END
ELSE IF @Index = 6
BEGIN
use DongYing_JiangRenYuHua
goto RunTask
END
ELSE IF @Index = 7
BEGIN
use DongYing_LiRenDao
goto RunTask
END
ELSE IF @Index = 8
BEGIN
use DongYing_MuLanJie
goto RunTask
END
ELSE IF @Index = 9
BEGIN
use DongYing_PLBB
goto RunTask
END
ELSE IF @Index = 10
BEGIN
use HuHeHaoTe_FeiWen
goto RunTask
END
ELSE IF @Index = 11
BEGIN
use HuHeHaoTe_HeQi
goto RunTask
END
ELSE IF @Index = 12
BEGIN
use HuHeHaoTe_YunXin
goto RunTask
END
ELSE IF @Index = 13
BEGIN
use JiNan_ABiao
goto RunTask
END
ELSE IF @Index = 14
BEGIN
use JiNan_ATao
goto RunTask
END
ELSE IF @Index = 15
BEGIN
use JiNan_Great
goto RunTask
END
ELSE IF @Index = 16
BEGIN
use JiNan_JinZhi
goto RunTask
END
ELSE IF @Index = 17
BEGIN
use JiNan_MeiShang
goto RunTask
END
ELSE IF @Index = 18
BEGIN
use JiNan_MingGe
goto RunTask
END
ELSE IF @Index = 19
BEGIN
use JiNan_ShangPin
goto RunTask
END
ELSE IF @Index = 20
BEGIN
use JiNan_XiuMuMing
goto RunTask
END
ELSE IF @Index = 21
BEGIN
use JinCheng_NiHaoPiaoLiang
goto RunTask
END
ELSE IF @Index = 22
BEGIN
use LaiYang_HuaYun
goto RunTask
END
ELSE IF @Index = 23
BEGIN
use LaiZhou_MangGuo
goto RunTask
END
ELSE IF @Index = 24
BEGIN
use LiaoCheng_ShiJiJinDian
goto RunTask
END
ELSE IF @Index = 25
BEGIN
use LinYi_DaXiangGang
goto RunTask
END
ELSE IF @Index = 26
BEGIN
use LinYi_DiFanNi
goto RunTask
END
ELSE IF @Index = 27
BEGIN
use QingDao_AC
goto RunTask
END
ELSE IF @Index = 28
BEGIN
use QingDao_DaDaShiDa
goto RunTask
END
ELSE IF @Index = 29
BEGIN
use QingDao_DaLiangZao
goto RunTask
END
ELSE IF @Index = 30
BEGIN
use QingDao_FengHuangMingLiu
goto RunTask
END
ELSE IF @Index = 31
BEGIN
use QingDao_FuJun
goto RunTask
END
ELSE IF @Index = 32
BEGIN
use QingDao_GuBeiShaLong
goto RunTask
END
ELSE IF @Index = 33
BEGIN
use QingDao_HeChen
goto RunTask
END
ELSE IF @Index = 34
BEGIN
use QingDao_HongRenGuan
goto RunTask
END
ELSE IF @Index = 35
BEGIN
use QingDao_KeLin
goto RunTask
END
ELSE IF @Index = 36
BEGIN
use QingDao_LaFeiPaiRui
goto RunTask
END
ELSE IF @Index = 37
BEGIN
use QingDao_MaLin
goto RunTask
END
ELSE IF @Index = 38
BEGIN
use QingDao_ManXiu
goto RunTask
END
ELSE IF @Index = 39
BEGIN
use QingDao_ME
goto RunTask
END
ELSE IF @Index = 40
BEGIN
use QingDao_MeiGe
goto RunTask
END
ELSE IF @Index = 41
BEGIN
use QingDao_MingYu
goto RunTask
END
ELSE IF @Index = 42
BEGIN
use QingDao_NiSiKa
goto RunTask
END
ELSE IF @Index = 43
BEGIN
use QingDao_NiSiKa_DRF
goto RunTask
END
ELSE IF @Index = 44
BEGIN
use QingDao_NiSiKa_JiaoZhou
goto RunTask
END
ELSE IF @Index = 45
BEGIN
use QingDao_PuXin
goto RunTask
END
ELSE IF @Index = 46
BEGIN
use QingDao_QiShang
goto RunTask
END
ELSE IF @Index = 47
BEGIN
use QingDao_ShangDiLi
goto RunTask
END
ELSE IF @Index = 48
BEGIN
use QingDao_ShaXuan
goto RunTask
END
ELSE IF @Index = 49
BEGIN
use QingDao_SiNuoMei
goto RunTask
END
ELSE IF @Index = 50
BEGIN
use QingDao_Sweet
goto RunTask
END
ELSE IF @Index = 51
BEGIN
use QingDao_XiaoJun
goto RunTask
END
ELSE IF @Index = 52
BEGIN
use QingDao_YanSe
goto RunTask
END
ELSE IF @Index = 53
BEGIN
use QingDao_ZiRanFaZe
goto RunTask
END
ELSE IF @Index = 54
BEGIN
goto RunTask
END
ELSE IF @Index = 55
BEGIN
goto RunTask
END
ELSE IF @Index = 56
BEGIN
--use SaiDao_Dev
goto RunTask
END
ELSE IF @Index = 57
BEGIN
use SaiDao_Jike
goto RunTask
END
ELSE IF @Index = 58
BEGIN
use SaiDao_NingXia
goto RunTask
END
ELSE IF @Index = 59
BEGIN
use SaiDao_ShanXi
goto RunTask
END
ELSE IF @Index = 60
BEGIN
use SaiDao_ShanXiDemo
goto RunTask
END
ELSE IF @Index = 61
BEGIN
use SaiDaoDemo
goto RunTask
END
ELSE IF @Index = 62
BEGIN
use ShanTou_Demo1
goto RunTask
END
ELSE IF @Index = 63
BEGIN
use ShouGuang_JinGongZi
goto RunTask
END
ELSE IF @Index = 64
BEGIN
use ShouGuang_ShaXuan
goto RunTask
END
ELSE IF @Index = 65
BEGIN
use TaiYuan_BaYa
goto RunTask
END
ELSE IF @Index = 66
BEGIN
use TaiYuan_ChengYi_01
goto RunTask
END
ELSE IF @Index = 67
BEGIN
use TaiYuan_ChengYi_02
goto RunTask
END
ELSE IF @Index = 68
BEGIN
use TaiYuan_FaXianTa
goto RunTask
END
ELSE IF @Index = 69
BEGIN
use TaiYuan_FengGe
goto RunTask
END
ELSE IF @Index = 70
BEGIN
use TaiYuan_HeTangYueSe
goto RunTask
END
ELSE IF @Index = 71
BEGIN
use TaiYuan_JinRiShuoFa
goto RunTask
END
ELSE IF @Index = 72
BEGIN
use TaiYuan_ShaXuan_02
goto RunTask
END
ELSE IF @Index = 73
BEGIN
use TaiYuan_TouFaChangLe
goto RunTask
END
ELSE IF @Index = 74
BEGIN
use TaiYuan_XiMenXuan
goto RunTask
END
ELSE IF @Index = 75
BEGIN
use TaiYuan_XinGanJue
goto RunTask
END
ELSE IF @Index = 76
BEGIN
use TaiYuan_ZhouJi
goto RunTask
END
ELSE IF @Index = 77
BEGIN
use WeiFang_RuiLi
goto RunTask
END
ELSE IF @Index = 78
BEGIN
use WeiFang_XiMei
goto RunTask
END
ELSE IF @Index = 79
BEGIN
use XiaoYi_OSA
goto RunTask
END
ELSE IF @Index = 80
BEGIN
use XiNing_MingZhi
goto RunTask
END
ELSE IF @Index = 81
BEGIN
use XinZhou_BaiTianE
goto RunTask
END
ELSE IF @Index = 82
BEGIN
use YangQuan_ManDu
goto RunTask
END
ELSE IF @Index = 83
BEGIN
use YanTai_RunSiFang
goto RunTask
END
ELSE IF @Index = 84
BEGIN
use YinChuan_TX
goto RunTask
END
ELSE IF @Index = 85
BEGIN
use YunCheng_ShouXuan
goto RunTask
END
ELSE IF @Index = 86
BEGIN
use ZhengZhou_AFang
goto RunTask
END
ELSE IF @Index = 87
BEGIN
use ZhengZhou_AMaNi
goto RunTask
END
ELSE IF @Index = 88
BEGIN
use ZhengZhou_GuangPai
goto RunTask
END
ELSE IF @Index = 89
BEGIN
use ZhengZhou_HaiRunManHaDun
goto RunTask
END
ELSE IF @Index = 90
BEGIN
use ZhengZhou_HaiRunWenGeHua
goto RunTask
END
ELSE IF @Index = 91
BEGIN
use ZhengZhou_HuiShang
goto RunTask
END
ELSE IF @Index = 92
BEGIN
use ZhengZhou_JiangRenZuHe
goto RunTask
END
ELSE IF @Index = 93
BEGIN
use ZhengZhou_JinShang
goto RunTask
END
ELSE IF @Index = 94
BEGIN
use ZhengZhou_JueShiMingJian
goto RunTask
END
ELSE IF @Index = 95
BEGIN
use ZhengZhou_KaKa
goto RunTask
END
ELSE IF @Index = 96
BEGIN
use ZhengZhou_LiShuangShuang
goto RunTask
END
ELSE IF @Index = 97
BEGIN
use ZhengZhou_PiaoLiangBaoBei
goto RunTask
END
ELSE IF @Index = 98
BEGIN
use ZhengZhou_SiYiShaXuan
goto RunTask
END
ELSE IF @Index = 99
BEGIN
use ZhengZhou_TianQi
goto RunTask
END
ELSE IF @Index = 100
BEGIN
use ZhengZhou_XinYinXiang
goto RunTask
END
ELSE IF @Index = 101
BEGIN
use ZhengZhou_YinChuan
goto RunTask
END
ELSE IF @Index = 102
BEGIN
use ZhengZhou_YiPinJianSu
goto RunTask
END
ELSE IF @Index = 103
BEGIN
use ZhengZhou_YiShaLong
goto RunTask
END
ELSE IF @Index = 104
BEGIN
use ZiBo_YanYi
goto RunTask
END
PRINT 'END'