
---copia a tablas clave de la básica

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[_errores]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[_errores](
	[fechaModificacion] [smalldatetime] NOT NULL DEFAULT (getdate()),
	[error] [varchar](200) NULL DEFAULT (''),
	[error_codigo] [varchar](200) NULL DEFAULT (''),
	[seguimiento] [varchar](2000) NULL DEFAULT (''),
	[version] [varchar](100) NULL DEFAULT (''),
	[cliente] [varchar](200) NULL DEFAULT (''),
	[id_usuario_modifico] [int] NULL DEFAULT ((0))
) ON [PRIMARY]
END



IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ins_error]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[ins_error]

GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[ins_error]
	@p_error varchar(200),
	@p_error_codigo varchar(200),
	@p_seguimiento varchar(2000),
	@p_version varchar(100),
	@p_cliente varchar(200),
	@p_id_usuario_Modifico int
	
AS
BEGIN
	DECLARE @v_id int

	INSERT INTO [_errores]
           ([fechaModificacion]
           ,[error]
           ,[error_codigo]
           ,[seguimiento]
           ,[version]
           ,[cliente]
           ,[id_usuario_modifico])
     VALUES
           (getdate(),
			@p_error,
            @p_error_codigo,
            @p_seguimiento,
			@p_version,
			@p_cliente,
			@p_id_usuario_modifico)
		
		SET @v_id = scope_identity()

SELECT @v_id as id
RETURN @v_id
END
