dbo.sp_cuit_aleatorio

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.sp_cuit_aleatorio
 
AS
BEGIN
 SET NOCOUNT ON;
 declare @i int = 1
 declare @cuit varchar(20)
 declare @cuits table (cuit varchar(20))
 
 while (@i<=5)
 begin
  SELECT @cuit = identificacion 
  FROM padrones
  WHERE habilitado = 1 and identificador = 'CUIT'
  and identificacion like '2%'
  and id_padron = (select ROUND(((MAX(padrones.id_padron) - 1) * RAND() + 0), 0) from padrones)
  if (@cuit != '') 
  begin
  if (select count(*) from @cuits where cuit = @cuit) = 0
   begin
   set @i = @i + 1 
   insert into @cuits values (@cuit) 
   end 
  end 
 end 
 
 set @i  = 1
 while (@i<=5)
 begin
  SELECT @cuit = identificacion 
  FROM padrones
  WHERE habilitado = 1 and identificador = 'CUIT'
  and identificacion like '3%'
  and id_padron = (select ROUND(((MAX(padrones.id_padron) - 1) * RAND() + 0), 0) from padrones)
  if (@cuit != '') 
  begin
  if (select count(*) from @cuits where cuit = @cuit) = 0
   begin
   set @i = @i + 1 
   insert into @cuits values (@cuit) 
   end 
  end 
 end 
 
 select cuit from @cuits

END

GO

Depends On

1

Used By

No items found