1、不带输出的SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER proc [dbo].[InsertShiGongJiao] @number varchar(100), @companyindex int, @lineid int, @stationid int, @direct int, @stationname nvarchar(50), @stationindex int, @distance int, @type int as MERGE dbo.t_BusArrive_ShiGongJiao AS target USING (SELECT @number n) AS source ON (target.number=source.n) WHEN MATCHED THEN UPDATE SET companyindex=@companyindex, lineid=@lineid, direct=@direct, stationname=@stationname, stationid=@stationid, stationindex=@stationindex, distance=@distance, type=@type, updatetime=GETDATE() WHEN NOT MATCHED THEN INSERT(number,lineid,companyindex,direct,stationid,stationname,distance,stationindex,updatetime,type) VALUES( @number,@lineid,@companyindex,@direct,@stationid,@stationname,@distance,@stationindex,GETDATE(),@type); 2、带输出的
ALTER PROCEDURE [dbo].[FG_BM_MakeLSH_test] ( @TYPE VARCHAR(20), @mc VARCHAR(12), @lsh INT OUTPUT) AS MERGE FGHIS5_ZY.dbo.住院_编码流水号 AS T USING(SELECT @mc n,@TYPE t) AS source ON (T.名称=source.n AND T.分类=source.t) WHEN MATCHED THEN UPDATE SET 流水号 = 流水号 + @lsh,更新时间=GETDATE() WHEN NOT MATCHED THEN INSERT(分类,名称,流水号,创建时间)VALUES (@TYPE,@mc,0,GETDATE()) OUTPUT Inserted.流水号 as 流水号;
时间: 2024-10-22 06:53:12