Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incrementing folio problem
Message
From
30/05/2013 12:14:36
 
 
To
30/05/2013 11:34:36
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01575144
Message ID:
01575154
Views:
56
>Hi,
>
>We have a folio (unique number) which needs to be incremented by one every time a user needs it.
>The problem is that SQL Servers seems to hung and never returns the incremented number. This happens when we have concurrency of several users.
>
>The code is the following:
>
>
>
>USE [Cal_hon_Desa]
>GO
>/****** Object:  StoredProcedure [dbo].[Sel_Trae_Folio_ICS]    Script Date: 05/30/2013 09:34:10 ******/
>SET ANSI_NULLS ON
>GO
>SET QUOTED_IDENTIFIER ON
>GO
>
>
>-- =============================================
>-- Author:        xxxxx
>-- Create date: 11-01-2012
>-- Description:   Selecciona los datos de operacion a calcular
>-- =============================================
>ALTER PROCEDURE [dbo].[Sel_Trae_Folio_ICS]
>
>AS
>BEGIN
>      Select Folio_TB_ics from PRM_Folios
>            UPDATE dbo.PRM_Folios
>      SET Folio_TB_ICS = Folio_TB_ics + 1
>END
>
>
>
>Any ideas on how to make this code better or what we are doing wrong?
>
>Thanks,
>Daniel
store next value
   DECLARE @Folio_TB_ics INT
   UPDATE dbo.PRM_Folios
   SET  @Folio_TB_ics = Folio_TB_ics
      ,    Folio_TB_ICS = Folio_TB_ics + 1
   SELECT @Folio_TB_ics
store last value
   DECLARE @Folio_TB_ics INT
   UPDATE dbo.PRM_Folios
   SET  @Folio_TB_ics = Folio_TB_ics = Folio_TB_ics + 1
   SELECT @Folio_TB_ics
Previous
Reply
Map
View

Click here to load this message in the networking platform