使用return返回
--create pro USE yfb go create proc cwqi_test_pro( @newName varchar(20) out, @oldName varchar(20) in ) as begin set @newName=@oldName return 1 end --run pro DECLARE @newName varchar(20) DECLARE @oldName varchar(20) DECLARE @result bit EXEC @result=cwqi_test_pro @newName,@oldName=‘cwqi_pro‘ select @result --drop pro drop proc cwqi_test_pro
2. 使用out参数返回
--create pro USE yfb go create proc cwqi_test_pro_out( @newName varchar(20) out, @oldName varchar(20) in ) as begin --set NOCOUNT on 不返回计数 set @newName=@oldName end --run pro DECLARE @newName varchar(20) DECLARE @oldName varchar(20) EXEC cwqi_test_pro_out @newName out,@oldName=‘cwqi_pro‘ select @newName --drop pro drop proc cwqi_test_pro_out