

/****** Objeto:  Table [dbo].[zzu_itemRentaSap]    Fecha de la secuencia de comandos: 04/26/2013 15:29:40 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[zzu_itemRentaSap]') AND type in (N'U'))
DROP TABLE [dbo].[zzu_itemRentaSap]
GO
/****** Objeto:  Table [dbo].[zzu_itemRentaSap]    Fecha de la secuencia de comandos: 04/26/2013 15:28:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[zzu_itemRentaSap](
	[id] [int] IDENTITY(0,1) NOT NULL,
	[uid] [varchar](500) NOT NULL,
	[eid] [varchar](50) NOT NULL,
	[id_usuario_modifico] [int] NOT NULL DEFAULT ((0)),
	[id_usuario_creo] [int] NOT NULL  DEFAULT ((0)),
	[fechaModificacion] [datetime] NOT NULL  DEFAULT (getdate()),
	[fechaCreacion] [smalldatetime] NOT NULL  DEFAULT (getdate()),
	[active] [bit] NOT NULL   DEFAULT ((1)),
	[codigo] [varchar](100) NOT NULL,
	[descripcion] [varchar](300) NULL DEFAULT '',
	[cantidad] [float] NOT NULL   DEFAULT ((0)),
	[costo] [money] NOT NULL DEFAULT ((0)),
	[id_alquiler] [int] NOT NULL   DEFAULT ((0)),
 CONSTRAINT [PK_int_serialesAlquiler] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

GO
/****** Objeto:  StoredProcedure [dbo].[ins_zzu_itemRentaSap]    Fecha de la secuencia de comandos: 04/27/2013 11:59:12 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ins_zzu_itemRentaSap]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[ins_zzu_itemRentaSap]
GO
/****** Objeto:  StoredProcedure [dbo].[ins_zzu_itemRentaSap]    Fecha de la secuencia de comandos: 04/26/2013 15:31:12 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[ins_zzu_itemRentaSap]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_codigo varchar(100),
		@p_descripcion varchar(300),
		@p_cantidad float,
		@p_costo money,
		@p_id_alquiler int
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [zzu_itemRentaSap]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[codigo],
			[descripcion],
			[cantidad],
			[costo],
			[id_alquiler])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_codigo,
			@p_descripcion,
			@p_cantidad,
			@p_costo,
			@p_id_alquiler)
		SET @v_id = scope_identity()
UPDATE [zzu_itemRentaSap] set [uid] = [uid] + '_' + convert(varchar(20),@v_id) where [id]=@v_id
SELECT @v_id as id
RETURN @v_id
END
 ----------------------

