You are on page 1of 6

BUENO AHORA LES COMPARTO ESTE SCRIPT DE BASE DE DATOS VENTAS.. USE [BDventas] GO /****** Object: Table [dbo].

[Proveedor] Script Date: 07/06/2013 21:44:59 *** ***/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Proveedor]( [cod_proveedor] [char](10) NOT NULL, [Nombre] [varchar](50) NULL, [Direccion] [varchar](50) NULL, [telefono] [char](10) NULL, [Ruc] [char](10) NULL, CONSTRAINT [PK_Proveedor] PRIMARY KEY CLUSTERED ( [cod_proveedor] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, AL LOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[usuario] Script Date: 07/06/2013 21:44:59 ***** */ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[usuario]( [cod_usu] [char](10) NOT NULL, [cod_emp] [char](10) NOT NULL, [nivel_usu] [varchar](2) NOT NULL, [nom_usu] [varchar](30) NOT NULL, [password] [varchar](10) NOT NULL, [activo] [varchar](2) NOT NULL, PRIMARY KEY CLUSTERED ( [cod_usu] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, AL LOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[Tipo_pago] Script Date: 07/06/2013 21:44:59 *** ***/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO

[descripcion] [varchar](50) NULL. [direccion] [nchar](10) NULL. [nombres] [varchar](60) NULL. IGNORE_DUP_KEY = OFF. ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo]. AL LOW_ROW_LOCKS = ON. [descripcion] [varchar](50) NULL.[Unidad_Medida] Script Date: 07/06/2013 21:44:59 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON . AL LOW_ROW_LOCKS = ON. CONSTRAINT [PK_Clientes] PRIMARY KEY CLUSTERED ( [cod_clie] ASC )WITH (PAD_INDEX = OFF. [ruc] [char](12) NULL. [telefono] [char](10) NULL. ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo]. IGNORE_DUP_KEY = OFF.[Categoria1]( [cod_cate] [char](10) NOT NULL.[Clientes] Script Date: 07/06/2013 21:44:59 **** **/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Clientes]( [cod_clie] [char](10) NOT NULL. STATISTICS_NORECOMPUTE = OFF.[Tipo_pago]( [cod_tipo_pago] [char](10) NOT NULL. STATISTICS_NORECOMPUTE = OFF. CONSTRAINT [PK_Tipo_pago] PRIMARY KEY CLUSTERED ( [cod_tipo_pago] ASC )WITH (PAD_INDEX = OFF. IGNORE_DUP_KEY = OFF. ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo]. CONSTRAINT [PK_Categoria1] PRIMARY KEY CLUSTERED ( [cod_cate] ASC )WITH (PAD_INDEX = OFF. AL LOW_ROW_LOCKS = ON.CREATE TABLE [dbo].[Categoria1] Script Date: 07/06/2013 21:44:59 ** ****/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo]. STATISTICS_NORECOMPUTE = OFF.

[pre_compra] [decimal](10. [stock] [int] NULL. [telefono] [nchar](10) NULL.[Empleado] Script Date: 07/06/2013 21:44:59 **** **/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo]. [des] [varchar](60) NULL.[Unidad_Medida]( [cod_unidad] [char](10) NOT NULL. [direccion] [varchar](50) NULL. ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo]. [Descripcion] [varchar](50) NULL. [cod_unidad] [char](10) NULL. AL LOW_ROW_LOCKS = ON. [Nomusu] [varchar](50) NULL.GO SET ANSI_PADDING ON GO CREATE TABLE [dbo]. [pre_venta] [decimal](10. [fecha_ingreso] [datetime] NULL. IGNORE_DUP_KEY = OFF. 2) NULL. 2) NULL. [Nombre] [varchar](50) NULL.[Producto]( [cod_pro] [char](10) NOT NULL. ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[Empleado]( [cod_empleado] [char](10) NOT NULL. [cod_usu] [char](10) NULL.[Producto] Script Date: 07/06/2013 21:44:59 **** **/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo]. [cod_cate] [char](10) NULL. CONSTRAINT [PK_Empleado] PRIMARY KEY CLUSTERED ( . [fecha_vencimiento] [datetime] NULL. STATISTICS_NORECOMPUTE = OFF. AL LOW_ROW_LOCKS = ON. STATISTICS_NORECOMPUTE = OFF. IGNORE_DUP_KEY = OFF. CONSTRAINT [PK_Unidad_Medida] PRIMARY KEY CLUSTERED ( [cod_unidad] ASC )WITH (PAD_INDEX = OFF. CONSTRAINT [PK_Producto] PRIMARY KEY CLUSTERED ( [cod_pro] ASC )WITH (PAD_INDEX = OFF. [cod_prov] [char](10) NULL.

[cantidad] [char](4) NULL. STATISTICS_NORECOMPUTE LOW_ROW_LOCKS = ON.[Boleta]( [Num_Boleta] [char](10) NOT NULL.[buscar] @fechaini datetime. @fechafinal datetime as = OFF. 2) NULL. IGNORE_DUP_KEY = OFF. [nom_pro] [varchar](50) NULL. [importe] [decimal](10.[Detalle_boleta] 9 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo]. [total] [decimal](10. AL [PRIMARY] Script Date: 07/06/2013 21:44:5 Script Date: 07/06/2013 21:44 . 2) NULL. [cod_tipo_pago] [char](10) NULL. IGNORE_DUP_KEY = OFF. [cod_cli] [char](10) NULL. [fecha] [datetime] NULL.[buscar] :57 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create procedure [dbo]. CONSTRAINT [PK_Boleta] PRIMARY KEY CLUSTERED ( [Num_Boleta] ASC )WITH (PAD_INDEX = OFF. STATISTICS_NORECOMPUTE LOW_ROW_LOCKS = ON. ALLOW_PAGE_LOCKS = ON) ON ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[Boleta] Script / SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo]. [cod_pro] [char](10) NULL.[Detalle_boleta]( [num_boleta] [char](10) NOT NULL. AL [PRIMARY] Date: 07/06/2013 21:44:59 ****** = OFF. 2) NULL ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: StoredProcedure [dbo]. [precio_venta] [decimal](10. ALLOW_PAGE_LOCKS = ON) ON ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[cod_empleado] ASC )WITH (PAD_INDEX = OFF. [cod_empleado] [char](10) NULL.

[Boleta] CHECK CONSTRAINT [FK_Boleta_Tipo_pago] GO /****** Object: ForeignKey [FK_Detalle_boleta_Boleta1] Script Date: 07/06/20 13 21:44:59 ******/ ALTER TABLE [dbo].[Empleado] WITH CHECK ADD CONSTRAINT [FK_Empleado_usuario1] FOREIGN KEY([cod_usu]) REFERENCES [dbo].[Detalle_boleta] WITH CHECK ADD CONSTRAINT [FK_Detalle_bolet a_Boleta1] FOREIGN KEY([num_boleta]) REFERENCES [dbo].[Detalle_boleta] WITH CHECK ADD CONSTRAINT [FK_Detalle_bolet a_Producto] FOREIGN KEY([cod_pro]) REFERENCES [dbo].[Clientes] ([cod_clie]) GO ALTER TABLE [dbo].[Detalle_boleta] CHECK CONSTRAINT [FK_Detalle_boleta_Producto] GO /****** Object: ForeignKey [FK_Empleado_usuario] Script Date: 07/06/2013 21: 44:59 ******/ ALTER TABLE [dbo].[usuario] ([cod_usu]) GO ALTER TABLE [dbo].[Boleta] CHECK CONSTRAINT [FK_Boleta_Empleado] GO /****** Object: ForeignKey [FK_Boleta_Tipo_pago] Script Date: 07/06/2013 21: 44:59 ******/ ALTER TABLE [dbo].[Boleta] ([Num_Boleta]) GO ALTER TABLE [dbo].[Empleado] CHECK CONSTRAINT [FK_Empleado_usuario1] GO /****** Object: ForeignKey [FK_Producto_Categoria1] Script Date: 07/06/2013 21:44:59 ******/ .[Producto] ([cod_pro]) GO ALTER TABLE [dbo].[Detalle_boleta] CHECK CONSTRAINT [FK_Detalle_boleta_Boleta1] GO /****** Object: ForeignKey [FK_Detalle_boleta_Producto] Script Date: 07/06/2 013 21:44:59 ******/ ALTER TABLE [dbo].[Boleta] CHECK CONSTRAINT [FK_Boleta_Clientes] GO /****** Object: ForeignKey [FK_Boleta_Empleado] Script Date: 07/06/2013 21:4 4:59 ******/ ALTER TABLE [dbo].[Boleta] WITH CHECK ADD CONSTRAINT [FK_Boleta_Empleado] FORE IGN KEY([cod_empleado]) REFERENCES [dbo].[Empleado] CHECK CONSTRAINT [FK_Empleado_usuario] GO /****** Object: ForeignKey [FK_Empleado_usuario1] Script Date: 07/06/2013 21 :44:59 ******/ ALTER TABLE [dbo].[Empleado] WITH CHECK ADD CONSTRAINT [FK_Empleado_usuario] F OREIGN KEY([cod_usu]) REFERENCES [dbo].[Tipo_pago] ([cod_tipo_pago]) GO ALTER TABLE [dbo].[Empleado] ([cod_empleado]) GO ALTER TABLE [dbo].[Boleta] WITH CHECK ADD CONSTRAINT [FK_Boleta_Clientes] FORE IGN KEY([cod_cli]) REFERENCES [dbo].select*from boleta where fecha between @fechaini and @fechafinal GO /****** Object: ForeignKey [FK_Boleta_Clientes] Script Date: 07/06/2013 21:4 4:59 ******/ ALTER TABLE [dbo].[usuario] ([cod_usu]) GO ALTER TABLE [dbo].[Boleta] WITH CHECK ADD CONSTRAINT [FK_Boleta_Tipo_pago] FOR EIGN KEY([cod_tipo_pago]) REFERENCES [dbo].

[Producto] CHECK CONSTRAINT [FK_Producto_Unidad_Medida] GO .[Producto] CHECK CONSTRAINT [FK_Producto_Proveedor] GO /****** Object: ForeignKey [FK_Producto_Unidad_Medida] Script Date: 07/06/20 13 21:44:59 ******/ ALTER TABLE [dbo].[Producto] WITH CHECK ADD CONSTRAINT [FK_Producto_Unidad_Med ida] FOREIGN KEY([cod_unidad]) REFERENCES [dbo].[Producto] WITH CHECK ADD CONSTRAINT [FK_Producto_Categoria1 ] FOREIGN KEY([cod_cate]) REFERENCES [dbo].[Unidad_Medida] ([cod_unidad]) GO ALTER TABLE [dbo].[Proveedor] ([cod_proveedor]) GO ALTER TABLE [dbo].[Producto] WITH CHECK ADD CONSTRAINT [FK_Producto_Proveedor] FOREIGN KEY([cod_prov]) REFERENCES [dbo].[Producto] CHECK CONSTRAINT [FK_Producto_Categoria1] GO /****** Object: ForeignKey [FK_Producto_Proveedor] Script Date: 07/06/2013 2 1:44:59 ******/ ALTER TABLE [dbo].[Categoria1] ([cod_cate]) GO ALTER TABLE [dbo].ALTER TABLE [dbo].