复制某个用户的核算项目过滤方案到另外一个用户、多个用户、所有用户
1、
--复制某个用户的核算项目过滤方案到另外一个用户
--以演示账套为例,复制administrator的testttt方案给chy
DECLARE @FFrom NVARCHAR(255)
DECLARE @FTo NVARCHAR(255)
DECLARE @FFilter NVARCHAR(255)
--被复制的用户名
SET @FFrom = 'administrator'
--要复制到的用户名
SET @FTo = 'chy'
--要复制的过滤方案名称
SET @FFilter = 'testttt'
DELETE t1 FROM t_UserProfile t1
INNER JOIN t_User t2 ON t1.FUserID = t2.FUserID
WHERE t1.FCategory = 'BaseDate_Locate' AND t1.FKey = @FFilter AND t2.FName = @FTo
INSERT INTO t_UserProfile(FUserID,FCategory,FKey,FData,FBlobSize)
SELECT t3.FUserID,t1.FCategory,t1.FKey,t1.FData,t1.FBlobSize FROM t_UserProfile t1,t_User t2,t_User t3
WHERE t1.FCategory = 'BaseDate_Locate'
AND t1.FKey = @FFilter
AND t2.FName = @FFrom
AND t3.FName = @FTo
2、
--复制某个用户的核算项目过滤方案到多个用户
--以演示账套为例,复制administrator的testttt方案给chy、cpd
DECLARE @FFrom NVARCHAR(255)
DECLARE @FFilter NVARCHAR(255)
--被复制的用户名
SET @FFrom = 'administrator'
--要复制的过滤方案名称
SET @FFilter = 'testttt'
DELETE t1 FROM t_UserProfile t1
INNER JOIN t_User t2 ON t1.FUserID = t2.FUserID
WHERE t1.FCategory = 'BaseDate_Locate' AND t1.FKey = @FFilter
--括号内替换为要复制到的用户名
AND t2.FName IN ('chy','cpd')
INSERT INTO t_UserProfile(FUserID,FCategory,FKey,FData,FBlobSize)
SELECT t2.FUserID,t1.FCategory,t1.FKey,t1.FData,t1.FBlobSize FROM t_UserProfile t1,t_User t2
WHERE t1.FCategory = 'BaseDate_Locate'
AND t1.FKey = @FFilter
AND t1.FUserID = (SELECT FUserID FROM t_User t3 WHERE t3.FName = @FFrom)
--括号内替换为要复制到的用户名
AND t2.FName IN ('chy','cpd')
3、
--复制某个用户的核算项目过滤方案到所有用户
--以演示账套为例,复制administrator的testttt方案给所有
DECLARE @FFrom NVARCHAR(255)
DECLARE @FFilter NVARCHAR(255)
--被复制的用户名
SET @FFrom = 'administrator'
--要复制的过滤方案名称
SET @FFilter = 'testttt'
DELETE t1 FROM t_UserProfile t1
INNER JOIN t_User t2 ON t1.FUserID = t2.FUserID
WHERE t1.FCategory = 'BaseDate_Locate' AND t1.FKey = @FFilter
AND t2.FName <> @FFrom
INSERT INTO t_UserProfile(FUserID,FCategory,FKey,FData,FBlobSize)
SELECT t2.FUserID,t1.FCategory,t1.FKey,t1.FData,t1.FBlobSize FROM t_UserProfile t1,t_User t2
WHERE t1.FCategory = 'BaseDate_Locate'
AND t1.FKey = @FFilter
AND t1.FUserID = (SELECT FUserID FROM t_User t3 WHERE t3.FName = @FFrom)
AND t2.FName <> @FFrom
复制某个用户的核算项目过滤方案到另外一个用户、多个用户、所有用户
本文2024-09-16 16:26:12发表“k3wise知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3wise-9231.html