SQL Server: While cambio de cursores




declare @idbase as bigint
declare @Max int, @Ini int  

DECLARE @Tab1 TABLE(Id int IDENTITY(1,1) PRIMARY KEY NOT NULL, idbase bigint)
 
insert into @Tab1
select idbase from base with (nolock)

select @Max = count(*) from @Tab1      
set @Ini = 1      
WHILE @Ini < @Max + 1      
BEGIN
select @idbase = idbase from @Tab1 where Id = @Ini    
exec [PA_eliminarBase] @idbase;
Print cast(@idbase as nvarchar)          
   set @Ini = @Ini + 1  
END




declare @idbase as bigint
declare @Max int, @Ini int  
declare @fechadesde datetime;
declare @fechahasta datetime;
set @fechadesde = DATEADD(dd,-1,DATEADD(dd,DATEDIFF(dd,0,getdate()),0))
set @fechahasta = DATEADD(dd,-1,DATEADD(dd,DATEDIFF(dd,0,getdate()),0))
 

set @Max =20
set @Ini = 1      
WHILE @Ini < @Max + 1      
BEGIN

  set @fechadesde = DATEADD(dd,-1*@Ini,DATEADD(dd,DATEDIFF(dd,0,getdate()),0))
set @fechahasta = DATEADD(dd,-1*@Ini,DATEADD(dd,DATEDIFF(dd,0,getdate()),0))

print @fechadesde;

  exec dbo.PA_ingresarindicador @fechadesde, @fechahasta

  Print cast(@Ini as nvarchar)              
     set @Ini = @Ini + 1  
END 

Comentarios

Entradas populares