sql server存儲過程返回值示例代碼
以下代碼功能為添加管理員用戶
返回值相關語句
declare @return int
set @return =1
set @return=0
return @return
USE [HoverTreeCode]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- hovertree.com 添加管理員
-- =============================================
ALTER PROCEDURE [dbo].[Sp_HoverTree_PanelUser_Add]
@hvtusername NVARCHAR(20) ,--用戶名
@hvtpassword NVARCHAR(50) --密碼
AS
SET NOCOUNT ON
SET XACT_ABORT ON
declare @return int
BEGIN TRY
BEGIN TRANSACTION
--插入
INSERT hovertree_panelUser
( hvtusername ,
hvtpassword
)
SELECT @hvtusername ,
@hvtpassword
COMMIT TRANSACTION
set @return =1
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION
END
set @return=0
END CATCH
return @return