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/超旺账套.sql

92 lines
2.0 KiB

1 year ago
IF OBJECT_ID('sys_user_account') IS NULL
BEGIN
CREATE TABLE sys_user_account
(
[system_user] varchar(200),
[account_name] varchar(200),
PRIMARY KEY([system_user],[account_name])
)
END
GO
IF OBJECT_ID('set_user_account') IS NOT NULL
BEGIN
DROP PROC set_user_account
END
GO
CREATE PROC set_user_account
(
@system_user VARCHAR(200),
@account_names VARCHAR(7000)
)
AS
BEGIN
declare @table table
(
name varchar(200)
)
declare @str varchar(7000)
select @str = @account_names
declare @separator VARCHAR(1)
SET @separator = ','
set @str = @str+@separator
Declare @insertStr varchar(1000) --<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
Declare @newstr varchar(7500) --<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
set @insertStr = left(@str,charindex(@separator,@str)-1)
set @newstr = stuff(@str,1,charindex(@separator,@str),'')
Insert @table Values(@insertStr)
while(len(@newstr)>0)
begin
set @insertStr = left(@newstr,charindex(@separator,@newstr)-1)
Insert @table Values(@insertStr)
set @newstr = stuff(@newstr,1,charindex(@separator,@newstr),'')
end
delete sys_user_account where [system_user] = @system_user
insert sys_user_account([system_user],[account_name])
select @system_user,name
from @table
END
GO
IF OBJECT_ID('t_sys_zt') IS NULL
BEGIN
exec sp_rename 'sys_zt','t_sys_zt'
END
IF OBJECT_ID('sys_zt','V') IS NOT NULL
BEGIN
DROP VIEW sys_zt
END
GO
CREATE VIEW sys_zt
AS
SELECT xh,mc,is_default,
rq_zt_creat as rq_zt_creat,
yyyymm_qc,bm_dw,dw_mc,dw_dz,dw_tel,dw_cz,dw_khyh,dw_zh,dw_swdjh
FROM bhsys..t_sys_zt AS A,sys_user_account AS B
WHERE system_user = B.[system_user]
AND B.[account_name] = A.mc
GO
--------------------END-------------------------
/*
--ʾ<EFBFBD><EFBFBD>
EXEC set_user_account 'sql<EFBFBD><EFBFBD>½<EFBFBD><EFBFBD>','<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
--cd3
EXEC set_user_account 'MeiKongUser','KunMing_MeiKong'
EXEC set_user_account 'AnNing_NvRenFang','<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ů<EFBFBD>˷<EFBFBD>'
EXEC set_user_account 'KunMIngRuYiJia','KunMIngRuYiJia'
--
*/