Index issues

  • In worst case 4 for diffrent tables.

    Usually 1.

  • If the data is inside a transaction on the insert, it might not appear until the transaction commits.

  • I know,

    If we look on my sp it's look like this: (example to insert user I run this sp)

    USE [SynopSYS]

    GO

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [Synopsys].[usp_InsertUser]

    (

    @UserName NVARCHAR(50)

    )

    AS

    DECLARE @TransactionName NVARCHAR (50)

    DECLARE @TransactionMark NVARCHAR (50)

    DECLARE @userid INT

    SET @TransactionName = N'InserInto'

    SET @TransactionMark = N'Insert New User'

    SET @userid = 0

    BEGIN TRANSACTION @TransactionName WITH MARK @TransactionMark;

    SET NOCOUNT ON;

    /*begin stored procudore body*/

    IF NOT EXISTS (SELECT UserName FROM Synopsys.Users WHERE(UserName = @UserName))

    BEGIN

    INSERT INTO Synopsys.Users(UserName) VALUES(@UserName)

    SET @userid = @@IDENTITY

    END

    ELSE

    SET @userid = (SELECT Id FROM Synopsys.Users WHERE(UserName = @UserName))

    /*End stored procudore body*/

    IF @@ERROR = 0

    COMMIT TRANSACTION @TransactionName;

    ELSE

    ROLLBACK TRANSACTION @TransactionName;

    SELECT @userid

  • It cannot be possible that query will miss some of records. I suppose there is some problem with the query in the view. May be the where condition for filtering the records may not be correct. Please check

  • I'll take the advice given to me previous post. And check whether the query behaves differently with the BETWEEN operator and <> oprator.

    I will post my answer.

    Thanks for everybody.

Viewing 5 posts - 31 through 34 (of 34 total)

You must be logged in to reply to this topic. Login to reply