IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[sys_sql_command_loaddata]') AND type = 'P')
DROP PROCEDURE [dbo].[sys_sql_command_loaddata]
GO
create procedure [dbo].[sys_sql_command_loaddata](
@parseid int,
@prebank varchar(50),
@script varchar(2000) output
)AS
BEGIN

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @ttable varchar(50),@srcText varchar(200),@curInd int,@varType varchar(20) ,@script2 varchar(max),@hasUpDS int,
@varName varchar(20),@fromInd int  ,@toInd int,@dsname varchar(20),@tbname varchar(20),@glparseid int,@cmpid int

select @script=''
select @ttable=ttable,@glparseid=glparseid,@cmpid=cmpid
from sys_Sql_inf 
where parseid=@parseid
 
 select @curInd=1
 exec sys_sql_getNextSysVar @ttable,@curInd,@varType output,@dsname output,@fromInd output ,@toInd output
--结束判断
if (@varType is null or @dsname is null) -- 为空，忽略该变量
goto over1

--加载数据
select @tbname=tbname 
  from flatDSS
  where dsname=@dsname
  
exec sys_sql_loadtable @cmpid,@glparseid,@tbname,@prebank,@script2 output

if (@script2 is not null)
set @script=@script2

over1:
set @curInd=0

END