用友U8手工删除账套的SQL

DECLARE @AccID CHAR(3);
SET @AccID = '999';
--在此修改账套号
USE UFSystem;

--备份日志
DELETE  FROM UA_BackupLog
WHERE   cAcc_Id = @AccID;

--备份计划子表
DELETE  FROM UA_BackupPlans
WHERE   cAcc_Id = @AccID;

--备份计划
DELETE  FROM UA_BackupPlan
WHERE   cPlan_Id NOT IN ( SELECT    cPlan_Id
                          FROM      UA_BackupPlans );
                          
--操作员权限分配表
DELETE  FROM UA_HoldAuth
WHERE   cAcc_Id = @AccID;

--权限预置表
DELETE  FROM UA_Auth
WHERE   cAcc_Id = @AccID;

--流程图项目表
DELETE  FROM UA_FlowItems
WHERE   cAccId = @AccID;

--流程图线路表
DELETE  FROM UA_FlowLines
WHERE   cAccId = @AccID;

--单据编号生成控制表
DELETE  FROM UA_Identity
WHERE   cAcc_Id = @AccID;

--账套年度表
DELETE  FROM UA_Account_sub
WHERE   cAcc_Id = @AccID;

--上机日志
DELETE  FROM UA_Log
WHERE   cAcc_Id = @AccID;

--会计期间表
DELETE  FROM UA_Period
WHERE   cAcc_Id = @AccID;

--账套表
DELETE  FROM UA_Account
WHERE   cAcc_Id = @AccID;

--发送信息设置
DELETE  FROM UA_Message
WHERE   Account = @AccID;

--服务器配置信息表
DELETE  GDP_JccpConfigure
WHERE   UF_DB_NAME = @AccID; 

--账套数据库映射表
DELETE  FROM UA_AccountDatabase
WHERE   cAcc_Id = @AccID;

--分离数据库,激进点的可以直接删除数据库
USE master;
DECLARE AccCur CURSOR
FOR
    SELECT  name
    FROM    sysdatabases;
DECLARE @AccName VARCHAR(40);
OPEN AccCur;
FETCH NEXT FROM AccCur INTO @AccName;
WHILE ( @@fetch_status <> -1 )
    BEGIN
        IF ( @@fetch_status <> -2 )
            BEGIN
                IF ( LEFT(@AccName, 10) = 'UFDATA_' + @AccID )
                    AND LEN(@AccName) = 15
                    BEGIN
                        EXECUTE sp_detach_db @AccName;
                        PRINT '账套库' + @AccName + '已分离!';
                    END;
                IF @AccName = 'UFMeta_' + @AccID
                    BEGIN
                        EXECUTE sys.sp_detach_db @AccName;
                        PRINT '数据库' + @AccName + '已经分离';
                    END;
            END;
        FETCH NEXT FROM AccCur INTO @AccName;
    END;
CLOSE AccCur;
DEALLOCATE AccCur;
SELECT  '账套' + @AccID + '删除完成!';

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hello World,

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值