Community discussion forum

Very slow inserts using SqlCommand.ExecuteNonQuery()

  • 11 months ago
    Hi All, When I am trying to make lots of Inserts into my database ... it takes lots of time to insert using SqlCommand.ExecuteNonQuery(). Even though I have created an SP as following: ALTER PROCEDURE myProc ( @param1 varchar(50), @param2 int, @param3 decimal(18,0), @param4 decimal(18,0) ) AS BEGIN BEGIN TRAN DECLARE @result int; exec @result = sp_getapplock = 'Lock_Id', @LockMode = 'Exclusive'; IF @result = -3 BEGIN ROLLBACK TRANSACTION END ELSE BEGIN INSERT INTO myTable values(@param1, @param2, @param3, @param4) exec @result = sp_releaseapplock @Resources = 'LockId' COMMIT TRANSACTION END END END I am not sure, if the problem is with the above SP or any other reason coz of which, it takes such a long time to insert. Plz suggest !!! Thanks
  • 11 months ago
    i can't get u plz explain clearly thanks Selvi

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!