dbo.insertar_dependencia

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

2
Name Data Type Length Description
@id_padron int 4
@id_dependencia int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.insertar_dependencia
@id_padron int,
@id_dependencia int

AS


BEGIN
    SET NOCOUNT ON;
 /*
  declare @id int
 
  set @id = (select codigo_dependencia from padron_dependencias where id_padron = @id_padron and codigo_dependencia in(@id_dependencia))
  if(@id is null or @id <= 0)
  begin
  insert into padron_dependencias(id_padron,codigo_dependencia,created_by,visible,created) values (@id_padron,@id_dependencia,0,1,getdate())
  end
  */


 declare @today date = getdate()

 delete from padron_dependencias where id_padron = @id_padron and convert(date,created) < @today 
 insert into padron_dependencias(id_padron,  codigo_dependencia, created_by, visible, created) 
                         values (@id_padron, @id_dependencia,    0,          1,       getdate())

END 

GO

Used By

No items found