22,300
社区成员




EXEC @Flage = [AAA1] @ID --这样就可以得到返回值了
create procedure AAA1
@ID int
as
begin
set nocount on
begin tran
SET XACT_ABORT on
if exists(select 1 from em where id < @id )
return
if not exists(select 1 from em where id = 4)
insert into EM([ID], Mes, Det) values(4, '444', '444')
if exists(select [ID] from EM where [ID] = @ID)
update EM set Mes = '1111', Det = '111111' where [ID] = @ID
commit tran
end
DECLARE @IntVariable int;
DECLARE @SQLString nvarchar(500);
DECLARE @ParmDefinition nvarchar(500);
DECLARE @max_title varchar(30);
SET @IntVariable = 197;
SET @SQLString = N'SELECT @max_titleOUT = max(Title)
FROM AdventureWorks.HumanResources.Employee
WHERE ManagerID = @level';
SET @ParmDefinition = N'@level tinyint, @max_titleOUT varchar(30) OUTPUT';
EXECUTE sp_executesql @SQLString, @ParmDefinition, @level = @IntVariable, @max_titleOUT=@max_title OUTPUT;
SELECT @max_title;
sp_executesql