Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
3| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_cuit | varchar | 30 | |
| @p_cuit_inactivo | varchar | 30 | |
| @p_fecha_relacion | varchar | 50 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
EXEC insertar_cuit_inactivo_afip '279285526890','27602046317','2018-06-01'
SELECT * FROM cambios_cuit
*/
CREATE OR ALTER PROCEDURE dbo.insertar_cuit_inactivo_afip
-- Add the parameters for the stored procedure here
@p_cuit varchar(30),
@p_cuit_inactivo varchar(30),
@p_fecha_relacion varchar(50)
AS
BEGIN
SET NOCOUNT ON;
declare @id_padron int
declare @id_padron_inactivo int
begin try
if ((select COUNT(*) from cambios_cuit r
where r.cuit = @p_cuit and r.cuit_inactivo = @p_cuit_inactivo) = 0)
begin
set @id_padron = (select top 1 id_padron from padrones where identificacion = @p_cuit and habilitado = 1 and identificador in (select identificador from identificadores where country_code = 'AR'))
set @id_padron_inactivo = (select top 1 id_padron from padrones where identificacion = @p_cuit_inactivo and habilitado = 1 and identificador in (select identificador from identificadores where country_code = 'AR'))
insert into cambios_cuit
(
cuit,
id_padron,
cuit_inactivo,
id_padron_inactivo,
fecha,
visible,
origen_del_dato ,
created,
modified
)
values
(@p_cuit,
@id_padron,
@p_cuit_inactivo,
@id_padron_inactivo,
@p_fecha_relacion,
'1',
'AFIP',
GETDATE(),
null)
select 'ok' as ok
end
end try
begin catch
select ERROR_MESSAGE() as error
end catch
END
GO
GO
/*
EXEC insertar_cuit_inactivo_afip '279285526890','27602046317','2018-06-01'
SELECT * FROM cambios_cuit
*/
CREATE OR ALTER PROCEDURE dbo.insertar_cuit_inactivo_afip
-- Add the parameters for the stored procedure here
@p_cuit varchar(30),
@p_cuit_inactivo varchar(30),
@p_fecha_relacion varchar(50)
AS
BEGIN
SET NOCOUNT ON;
declare @id_padron int
declare @id_padron_inactivo int
begin try
if ((select COUNT(*) from cambios_cuit r
where r.cuit = @p_cuit and r.cuit_inactivo = @p_cuit_inactivo) = 0)
begin
set @id_padron = (select top 1 id_padron from padrones where identificacion = @p_cuit and habilitado = 1 and identificador in (select identificador from identificadores where country_code = 'AR'))
set @id_padron_inactivo = (select top 1 id_padron from padrones where identificacion = @p_cuit_inactivo and habilitado = 1 and identificador in (select identificador from identificadores where country_code = 'AR'))
insert into cambios_cuit
(
cuit,
id_padron,
cuit_inactivo,
id_padron_inactivo,
fecha,
visible,
origen_del_dato ,
created,
modified
)
values
(@p_cuit,
@id_padron,
@p_cuit_inactivo,
@id_padron_inactivo,
@p_fecha_relacion,
'1',
'AFIP',
GETDATE(),
null)
select 'ok' as ok
end
end try
begin catch
select ERROR_MESSAGE() as error
end catch
END
GO