-- SQL Manager Lite for SQL Server 3.8.0.5
-- ---------------------------------------
-- Host      : 
-- Database  : demos
-- Version   : Microsoft SQL Server  11.0.2100.60


CREATE DATABASE [demos]
ON PRIMARY
  ( NAME = [demos_Data],
    FILENAME = N'H:\...<Fijar la ruta del archivo>...\demos_Data.MDF',
    SIZE = 5 MB,
    MAXSIZE = 5 MB,
    FILEGROWTH = 10 % )
LOG ON
  ( NAME = [demos_Log],
    FILENAME = N'H:\...<Fijar la ruta del archivo>...\demos_Log.LDF',
    SIZE = 1 MB,
    MAXSIZE = 5 MB,
    FILEGROWTH = 10 % )
COLLATE Modern_Spanish_CI_AS
GO

USE [demos]
GO

--
-- Definition for user super-usuario : 
--

CREATE USER [super-usuario]
  FOR LOGIN [super-usuario]
  WITH DEFAULT_SCHEMA = [dbo]
GO

--
-- Definition for table banners : 
--

CREATE TABLE [dbo].[banners] (
  [IDBanner] int IDENTITY(1, 1) NOT NULL,
  [Banner] image NULL
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO

--
-- Definition for stored procedure EliminarImagen : 
--
GO
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE dbo.EliminarImagen
 @IDBanner int
AS
BEGIN
 delete from Banners where IDBanner = @IDBanner
END
GO

--
-- Definition for stored procedure InsertaImagen : 
--
GO
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE dbo.InsertaImagen
@Banner IMAGE,
@ID Integer OUT
AS
BEGIN
  /* Procedure body */   
  INSERT INTO 
    dbo.banners
  (
    Banner
  ) 
  VALUES (
    @Banner
  )  
  
  Set @ID = @@IDENTITY
END
GO

--
-- Definition for indices : 
--

ALTER TABLE [dbo].[banners]
ADD PRIMARY KEY CLUSTERED ([IDBanner])
WITH (
  PAD_INDEX = OFF,
  IGNORE_DUP_KEY = OFF,
  STATISTICS_NORECOMPUTE = OFF,
  ALLOW_ROW_LOCKS = OFF,
  ALLOW_PAGE_LOCKS = OFF)
ON [PRIMARY]
GO

