SQL Server Performance

i want to use old project stored procedure in my new project .

Discussion in 'SQL Server 2008 Questions [Archive Only - Closed]' started by Golden Heart, Jun 3, 2012.

  1. Golden Heart New Member

    This is my new project table and stored procedure . its used to insert data.and my second stored procedure is used to insert and Auto increment till one year when next year starts it will change to one again.that process i want to use in my new project table Transaction

    Table
    ID int
    Patient nvchar(50)
    E_TO nvchar(50)
    R_date datetime
    report_type nvchar(50)
    R_from int
    User_ID uniqueidentifier
    Patient_no int
    Patient_ID_NO numeric

    CREATE PROCEDURE [dbo].[usp_NEM_TRANSACTIONS]
    @Patient nvarchar(50),
    @E_TO nvarchar(50),
    @R_date datetime,
    @R_type int,
    @User_id uniqueidentifier,
    @ReportType nvarchar(50),
    @Patient_no int,
    @NID int OUTPUT
    AS
    BEGIN
    SET NOCOUNT ON;

    -Insert statements for procedure here
    INSERT INTO dbo.Transactions (Patient,E_TO,R_date,R_from,User_id,report_type,Patient_no)values (@Patient,@E_TO,@R_date,@R_type,@User_id,@ReportType,@Patient_no)
    SET @NID = SCOPE_IDENTITY()

    END

    And this is my old project table and stored procedure

    Table
    pk numeric (18,0)
    name varchar(50)
    trandate datetime
    id numeric (18,0)
    Create PROCEDURE [dbo].[spInsertItem]
    (
    @name varchar(50)

    )
    AS
    BEGIN

    declare @tempid numeric(18,0)
    set @tempid = 0;
    declare @idcnt numeric(18,0)
    select @idcnt =isnull( max(id),0) from newid where year(trandate)=year(getdate())
    if (@idcnt =0)
    set @tempid=1
    else
    set @tempid = @idcnt +1

    SET NOCOUNT ON; insert into newid(trandate,id,name) values(getdate(),@tempid,@name) SELECT id=@@IDENTITY;

    SET NOCOUNT OFF;
    END

Share This Page