ALTER TABLE LogPro ALTER COLUMN Observacion VARCHAR(2000)
GO
ALTER TABLE LogSys ALTER COLUMN Observacion VARCHAR(2000)
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsLogSys]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsLogSys]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpLogPro]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paUpLogPro]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsLogPro]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsLogPro]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsLogSys] @pmIdLog INT,@pmTipDoc VARCHAR(3),@pmDocumento INT,@pmIdCia CHAR(2)
,@pmFecha SMALLDATETIME,@pmTimeSys SMALLDATETIME,@pmIdUsuario VARCHAR(11),@pmNombre VARCHAR(50)
,@pmObservacion VARCHAR(2000),@pmIdTercero VARCHAR(16),@pmIdVehiculo VARCHAR(10),@pmEsCom BIT,@pmEliminado BIT,@pmModificado BIT
,@pmnModulo VARCHAR(20),@pmDsname VARCHAR(20)
AS
 INSERT INTO logSys (IdLog,TipDoc,Documento,IdCia,Fecha,TimeSys,IdUsuario,Nombre,Observacion,IdTercero,IdVehiculo,EsCom,Eliminado,Modificado,nModulo,Dsname)
 VALUES (@pmIdLog,@pmTipDoc,@pmDocumento,@pmIdCia,@pmFecha,@pmTimeSys,@pmIdUsuario,@pmNombre
,@pmObservacion,@pmIdTercero,@pmIdVehiculo,@pmEsCom,@pmEliminado,@pmModificado,@pmnModulo,@pmDsname)
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paUpLogPro]  @pmIdPro VARCHAR(20),@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmNomTabla VARCHAR(20)
,@pmIdUsuario VARCHAR(11),@pmNombre VARCHAR(50),@pmObservacion VARCHAR(2000),@pmNewTabla VARCHAR(20)
AS
 UPDATE LogPro SET IdUsuario=@pmIdUsuario,Nombre=@pmNombre,Observacion=@pmObservacion,NomTabla=@pmNewTabla
 WHERE IdPro=@pmIdPro AND Fecha=@pmFecha AND NomTabla=ISNULL(@pmNomTabla,NomTabla) AND IdCia=ISNULL(@pmIdCia,IdCia)
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsLogPro]  @pmIdLog INT,@pmIdPro VARCHAR(20),@pmIdCia CHAR(2)
,@pmFecha SMALLDATETIME,@pmTimeSys SMALLDATETIME,@pmIdUsuario VARCHAR(11),@pmNombre VARCHAR(50)
,@pmNomTabla VARCHAR(20), @pmObservacion VARCHAR(2000),@pmnModulo VARCHAR(20),@pmDsname VARCHAR(20)
AS
INSERT INTO LogPro (IdLog,IdPro,IdCia,Fecha,TimeSys,IdUsuario,Nombre,NomTabla,Observacion,nModulo,Dsname)
VALUES (@pmIdLog,@pmIdPro,@pmIdCia,@pmFecha,@pmTimeSys,@pmIdUsuario,@pmNombre,@pmNomTabla,@pmObservacion,@pmnModulo,@pmDsname)
GO
