SQL server 存储过程的编写

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_40155090/article/details/81083909

USE [数据库名称]

GO
/****** Object:  StoredProcedure [dbo].[insertbGait]    Script Date: 2018/7/17 15:51:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        liulaiyang
-- Create date: 20180704
-- Description:    test
-- =============================================
CREATE PROCEDURE [dbo].[insert+表名]
    -- Add the parameters for the stored procedure here
    
    @id    bigint out, //@加字段 数据类型 ,
    @gain    nvarchar,
    @image    varbinary(MAX)NULL=NULL    ,
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    DECLARE @MyTableVar table( id bigint);
    BEGIN TRY
        INSERT INTO bGait(gait,image)//对应字段
               output inserted.id into @MyTableVar
               VALUES(@gain,@image)//@+对应字段
        SET @id = (SELECT TOP 1 id FROM @MyTableVar)
    END TRY  
    BEGIN CATCH 
        RETURN 0
    END CATCH
END
RETURN 1

猜你喜欢

转载自blog.csdn.net/qq_40155090/article/details/81083909