Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Incrementing folio problem
Message
De
30/05/2013 12:14:36
 
 
À
30/05/2013 11:34:36
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01575144
Message ID:
01575154
Vues:
58
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform