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.
91 lines
2.0 KiB
91 lines
2.0 KiB
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) --截取后的第一个字符串
|
|
Declare @newstr varchar(7500) --截取第一个字符串后剩余的字符串
|
|
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-------------------------
|
|
|
|
/*
|
|
|
|
--示范
|
|
EXEC set_user_account 'sql登陆名','账套名称,账套2名称'
|
|
|
|
--cd3
|
|
EXEC set_user_account 'MeiKongUser','KunMing_MeiKong'
|
|
EXEC set_user_account 'AnNing_NvRenFang','云瑞女人坊'
|
|
EXEC set_user_account 'KunMIngRuYiJia','KunMIngRuYiJia'
|
|
|
|
--
|
|
|
|
*/
|
|
|