Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » SQL Server »

Stored procedure

Estas en el tema de Stored procedure en el foro de SQL Server en Foros del Web. Hola Soy novata en esto , y necesito ejecutar el siguiente stored procedure CREATE PROCEDURE Renombrar_Factura @F0 char(10), @F1 char(10) AS DECLARE @P0 as varchar(18), ...
  #1 (permalink)  
Antiguo 21/11/2005, 14:52
 
Fecha de Ingreso: noviembre-2005
Mensajes: 6
Antigüedad: 18 años, 5 meses
Puntos: 0
Stored procedure

Hola

Soy novata en esto , y necesito ejecutar el siguiente stored procedure

CREATE PROCEDURE Renombrar_Factura @F0 char(10), @F1 char(10) AS

DECLARE @P0 as varchar(18), @P1 as varchar(18), @Cuenta as int

DECLARE Claves_Facturas CURSOR FOR
Select rtrim(M.Claim_key), rtrim(replace(M.Claim_key,'-000','-00')) From Claim_Master M, Claim_Type T
Where M.Claim_key = T.Claim_key and T.Demand_date between @F0 and @F1 and M.Client_key like 'MY%' and len(rtrim(M.Claim_Key))=12


Select @Cuenta = 0
OPEN Claves_Facturas
FETCH NEXT FROM Claves_Facturas
INTO @P0, @P1

WHILE @@FETCH_STATUS = 0
BEGIN

PRINT @P0 + " - " + @P1

UPDATE claim_account_master SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_payment SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_contact SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_e_basic SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_finance SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_global SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_history SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_legal SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_master SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_n_basic SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_reference SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_sales SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE claim_type SET CLAIM_KEY = @P1 where claim_key = @P0
UPDATE collect_prompt SET CLAIM_KEY = @P1 where claim_key = @P0

FETCH NEXT FROM Claves_Facturas
INTO @P0, @P1

Select @Cuenta = @Cuenta + 1
END

PRINT "REGISTROS MODIFICADOS : " + str(@Cuenta,5,0)
CLOSE Claves_Facturas
DEALLOCATE Claves_Facturas

No tengo idea desde donde ejecutarlo, será desde el query analizer?, y con que sintaxis?, supongo que cuando un sp tiene parametros hay que especificarlos en la sintaxis de la ejecución, pero como se especifican los parametros para fechas? requiere fecha inicial y fecha final.

Muchas gracias saludos.
  #2 (permalink)  
Antiguo 21/11/2005, 15:28
Avatar de Mithrandir
Colaborador
 
Fecha de Ingreso: abril-2003
Mensajes: 12.106
Antigüedad: 21 años
Puntos: 25
Ejecutar un SP se suele hacer de esta forma:
Código:
EXEC miSP 'parametro1', 'parametro2'
Cosas más detalladas pueden ser cosas como:
Código:
DECLARE @resultado INT
DECLARE @variable_retorno INT OUTPUT
EXEC @resultado = dbo.miSP @param1 = 'parametro1', @param2 = 'parametro2', @resultado = @variable_retorno OUTPUT
PRINT @resultado
PRINT @variable_retorno
__________________
"El hombre, en su orgullo, creó a Dios a su imagen y semejanza."
Friedrich Nietzsche
  #3 (permalink)  
Antiguo 21/11/2005, 16:02
 
Fecha de Ingreso: noviembre-2005
Mensajes: 6
Antigüedad: 18 años, 5 meses
Puntos: 0
Muchas gracias :)
Saludos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas (incluyéndote)




La zona horaria es GMT -6. Ahora son las 00:56.