-- ´´½¨É¾³ýµÄ´æ´¢¹ý³Ì

CREATE PROCEDURE DeleteInterfacerecord	--´æ´¢¹ý³ÌÃû³Æ
    @MonthsAgo INT	--´æ´¢¹ý³Ì²ÎÊý
AS
BEGIN
    DECLARE @CutOffDate DATE = DATEADD(MONTH, -@MonthsAgo, GETDATE()); --ÉùÃ÷²ÎÊý
 
    DELETE FROM dt_Interfacerecord	--Êý¾Ý¿â±íÃû
    WHERE interface_createtime < @CutOffDate; --ÅÐ¶ÏÌõ¼þµÄÁÐÃû
END
GO
--	´´½¨Ìí¼ÓµÄ´æ´¢¹ý³Ì
CREATE PROCEDURE Add_inventory
    @SN NVARCHAR(255),
    @Name NVARCHAR(255),
		@FigureNumber NVARCHAR(255),
    @area NVARCHAR(15),
		@HeatNumber NVARCHAR(50),
    @BilletNumber INT,
		@OnlineTime datetime,
    @Operator NVARCHAR(50),
		@stationCode NVARCHAR(30),
    @jobID NVARCHAR(255),
		@ID uniqueidentifier,
    @remark NVARCHAR(max)
AS
BEGIN
    INSERT INTO dt_inventory (SN, Name,FigureNumber,area,HeatNumber,BilletNumber,OnlineTime,Operator,remark,stationCode,jobID,ID)
    VALUES (@SN, @Name,@FigureNumber,@area,@HeatNumber,@BilletNumber,@OnlineTime,@Operator,@remark,@stationCode,@jobID,@ID)
 
    -- ·µ»ØÐÂ²åÈëµÄÓÃ»§ID
    --SELECT SCOPE_IDENTITY() AS NewUserID;
END
GO

-- É¾³ýÃûÎª YourProcedureName µÄ´æ´¢¹ý³Ì
--IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Add_inventory]') AND type in (N'P', N'PC'))
--DROP PROCEDURE [dbo].Add_inventory;

-- ²éÑ¯ËùÓÐ´æ´¢¹ý³Ì
--SELECT * FROM information_schema.Routines WHERE ROUTINE_TYPE = 'PROCEDURE';

--Ö´ÐÐ²»ÐèÒª²ÎÊýµÄ´æ´¢¹ý³Ì
--EXEC DeleteInterfacerecord

--Ö´ÐÐ´ø²ÎÊýµÄ´æ´¢¹ý³Ì
--EXEC DeleteInterfacerecord @MonthsAgo = 6

--Ê¹ÓÃsp_executesql´æ´¢¹ý³Ì£¬ÕâÖÖ·½·¨¿ÉÒÔÌá¹©¶îÍâµÄ²ÎÊýÉùÃ÷ºÍÀàÐÍ¼ì²é£º
--DECLARE @Param1 NVARCHAR(100) = 'Value1', @Param2 INT = 123
--EXEC sp_executesql
--    N'EXEC YourProcedureName @Param1, @Param2',
--    N'@Param1 NVARCHAR(100), @Param2 INT',
--    @Param1, @Param2

--Ö±½ÓÔÚÓ¦ÓÃ³ÌÐò´úÂëÖÐµ÷ÓÃ´æ´¢¹ý³Ì£¬ÀýÈçÔÚC#ÖÐÊ¹ÓÃADO.NET£º
--using (SqlConnection conn = new SqlConnection(connectionString))
--{
--    SqlCommand cmd = new SqlCommand("YourProcedureName", conn);
--    cmd.CommandType = CommandType.StoredProcedure;
--    cmd.Parameters.AddWithValue("@Param1", "Value1");
--    cmd.Parameters.AddWithValue("@Param2", 123);
--    conn.Open();
--    cmd.ExecuteNonQuery();
--}