Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 10-03-2007
Kenlyr Kenlyr is offline
Miembro
 
Registrado: abr 2006
Posts: 13
Poder: 0
Kenlyr Va por buen camino
Problema con Store Procedure en SQL SERVER

Hola, tengo el siguiente Store Procedure en SQL SERVER el cual me convierte de Hexadecimal a Decimal, el problema es el siguiente que este Store Procedure debe de actualizar una tabla conviertiendo las filas del campo Hexadecimal a Decimal pero cuando lo ejecuto dura horas ejecutandose y no actualiza la tabla este es el codigo:

CREATE PROCEDURE [CONVERTIR_HEXADECIMAL]
AS
DBCC CHECKIDENT (Codigos, RESEED, 0)
-----------CONVERTIR SERIE DE HEX-DEC----------------------------
DECLARE @TRECORDS as int ,@ROW as int, @DEC as varchar(20),@Hex char(8),
@Hex1 char(8),@Hex2 char(8),@Longitud int,@counter int,@ch char(1),@num int,
@P int,@DEC1 INT,@DEC2 INT
SET @TRECORDS =(SELECT MAX(Num_FILA) FROM Codigos)
SET @ROW = 1
WHILE @ROW<=@TRECORDS
BEGIN
SET @HEX =(SELECT UPPER(SERIE_HEXADECIMAL) FROM Codigos WHERE Num_FILA=@ROW)
SET @DEC=''
-----------Convertir la primera parte de la serie a Decimal----------------------------
SET @HEX1=SUBSTRING(@HEX,1,2)
SET @Longitud=len(@HEX1)
SET @counter=2
SET @P=0
SET @DEC1 =0
SET @num = 0
WHILE @counter>=1
BEGIN
set @ch = substring(@HEX1,@counter,1)
if @ch = 'A' set @num=10
else
if @ch = 'B' set @num=11
else
if @ch = 'C' set @num=12
else
if @ch = 'D' set @num=13
else
if @ch = 'E' set @num=14
else
if @ch = 'F' set @num=15
else
if @ch between '0' and '9'
set @num =cast(substring(@HEX1,@counter,1) as int)
SET NOCOUNT ON
SET @DEC1 = @DEC1 + @num * POWER(16, @P)
SET @counter = @counter - 1
SET @P=@P+1
SET NOCOUNT OFF
END
-----------Convertir la segunda parte de la serie a Decimal----------------------------
SET @HEX2=SUBSTRING(@HEX,3,6)
SET @Longitud=len(@HEX2)
SET @counter=6
SET @P=0
SET @DEC2 =0
SET @num = 0
WHILE @counter>=1
BEGIN
set @ch = substring(@HEX2,@counter,1)
if @ch = 'A' set @num=10
else
if @ch = 'B' set @num=11
else
if @ch = 'C' set @num=12
else
if @ch = 'D' set @num=13
else
if @ch = 'E' set @num=14
else
if @ch = 'F' set @num=15
else
if @ch between '0' and '9'
set @num =cast(substring(@HEX2,@counter,1) as int)
SET NOCOUNT ON
SET @DEC2 = @DEC2 + @num * POWER(16, @P)
SET @counter = @counter - 1
SET @P=@P+1
SET NOCOUNT OFF
END
if len(@DEC1)< 3
set @DEC = substring('00000000',1,3-len(@DEC1))+cast(@DEC1 AS varchar(3))
else
set @DEC = cast(@DEC1 AS varchar(3))
if len(@DEC2)< 8
set @DEC =@DEC+substring('00000000',1,8-len(@DEC2))+cast(@DEC2 AS varchar(8))
else
set @DEC = @DEC +cast(@DEC2 as varchar(8))
UPDATE Codigos
SET SERIE_DECIMAL=@DEC
WHERE Num_FILA=@ROW
SET @ROW=@ROW + 1
END
GO

Que podria estar sucediendo??
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Problema con entrecomillado en sentencia select in dentro de un Store Procedure Caballero Negro MS SQL Server 3 12-01-2007 02:46:37
Migrar Store procedure Interbase a Msq Sql Server 2000 mrh_peru MS SQL Server 1 09-12-2006 20:51:06
Store procedure php jorgito MySQL 1 06-06-2006 08:55:12
Emplear Store Procedure La__X Conexión con bases de datos 5 19-01-2006 02:03:13
store procedure ronimaxh Firebird e Interbase 2 24-06-2003 20:20:22


La franja horaria es GMT +2. Ahora son las 16:40:51.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi