经试验,在查询分析器运行以下程序可以生成所要求的存储过程,谢谢aei135、nfarer 的建议
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
set ansi_warnings on
go
ALTER
PROCEDURE [DBO].[copy_ic_t_flow] AS
--从服务器下传数据
DECLARE @table_info_flow_no NUMERIC(9)
DECLARE @table_info_flow_no_MAX NUMERIC(9)
--从服务器下传数据出入库流水表数据
--获取下传出入库子表数据开始流水号
SELECT @table_info_flow_no=[flow_no]
FROM [ZIYOUFENG].[DBO].[table_info]
WHERE [table_name]='ic_t_flow'
INSERT INTO [ZIYOUFENG].[DBO].[ic_t_flow]
SELECT * FROM [janepmi.].[FASHION].[DBO].[ic_t_flow]
WHERE [sheet_no]>@table_info_flow_no
--保存相关下传点
SELECT @table_info_flow_no_MAX=MAX([sheet_no])
FROM [ZIYOUFENG].[DBO].[ic_t_flow]
PRINT '保存ic_t_flow 下传点'
UPDATE [ZIYOUFENG].[DBO].[table_info]
SET [flow_no]=@table_info_flow_no_MAX
WHERE [table_name]='ic_t_flow'
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO