USE [CECAMTRANSPARENCIA]
GO

/****** Object:  Table [dbo].[TRANSUsuario]    Script Date: 01/28/2014 13:39:20 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TRANSUsuario](
	[id_Usuario] [int] IDENTITY(1,1) NOT NULL,
	[nm_Usuario] [varchar](255) NOT NULL,
	[pw_Senha] [varchar](128) NOT NULL,
	[nm_UsuBloq] [varchar](50) NULL,
	[dt_UsuBloq] [datetime] NULL,
	[dt_Sr] [datetime] NULL,
	[cd_Sr] [char](1) NOT NULL,
	[cd_Controle] [char](44) NULL,
 CONSTRAINT [PK_TRANSUsuario] PRIMARY KEY CLUSTERED 
(
	[id_Usuario] 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

/****** Object:  Table [dbo].[TRANSDocumentoTipo]    Script Date: 01/28/2014 13:39:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TRANSDocumentoTipo](
	[id_DocumentoTipo] [int] IDENTITY(1,1) NOT NULL,
	[ds_DocumentoTipo] [varchar](60) NULL,
	[cd_Controle] [char](44) NULL,
	[nm_UsuBloq] [varchar](50) NULL,
	[dt_UsuBloq] [datetime] NULL,
	[dt_Sr] [datetime] NULL,
	[cd_Sr] [char](1) NOT NULL,
 CONSTRAINT [PK_TRANSDocumentoTipo] PRIMARY KEY CLUSTERED 
(
	[id_DocumentoTipo] 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

/****** Object:  Table [dbo].[TRANSDocumento]    Script Date: 01/28/2014 13:39:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TRANSDocumento](
	[id_Documento] [int] IDENTITY(1,1) NOT NULL,
	[id_DocumentoTipo] [int] NOT NULL,
	[nm_Documento] [varchar](50) NOT NULL,
	[im_Documento] [varchar](250) NULL,
	[dt_Documento] [date] NOT NULL,
	[nm_UsuBloq] [varchar](50) NULL,
	[dt_UsuBloq] [datetime] NULL,
	[dt_Sr] [datetime] NULL,
	[cd_Sr] [char](1) NOT NULL,
	[cd_Controle] [char](44) NULL,
 CONSTRAINT [PK_TRANSDocumento] PRIMARY KEY CLUSTERED 
(
	[id_Documento] 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

ALTER TABLE [dbo].[TRANSDocumento]  WITH NOCHECK ADD  CONSTRAINT [FK_TRANSDocumento_id_DocumentoTipo] FOREIGN KEY([id_DocumentoTipo])
REFERENCES [dbo].[TRANSDocumentoTipo] ([id_DocumentoTipo])
GO

ALTER TABLE [dbo].[TRANSDocumento] CHECK CONSTRAINT [FK_TRANSDocumento_id_DocumentoTipo]
GO


/****** Object:  Table [dbo].[TRANSPermissao]    Script Date: 10/02/2013 10:45:54 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TRANSPermissao](
	[id_Permissao] [int] IDENTITY(1,1) NOT NULL,
	[nm_UsuBloq] [varchar](50) NULL,
	[dt_UsuBloq] [datetime] NULL,
	[dt_Sr] [datetime] NULL,
	[cd_Permissao] [char](1) NOT NULL,
	[cd_Controle] [char](44) NULL,
 CONSTRAINT [PK_TRANSPermissao] PRIMARY KEY CLUSTERED 
(
	[id_Permissao] 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

INSERT INTO [CECAMTRANSPARENCIA].[dbo].[TRANSPermissao]
           ([nm_UsuBloq]
           ,[dt_UsuBloq]
           ,[dt_Sr]
           ,[cd_Permissao]
           ,[cd_Controle])
     VALUES
           (null
           ,null
           ,null
           ,1
           ,null)
GO


INSERT INTO [CECAMTRANSPARENCIA].[dbo].[TRANSUsuario]
           ([nm_Usuario]
           ,[pw_Senha]
           ,[nm_UsuBloq]
           ,[dt_UsuBloq]
           ,[dt_Sr]
           ,[cd_Sr]
           ,[cd_Controle])
     VALUES
           ('cecamportal'
           ,'BDD692175699AB37C6CB6C70E51F2FE785FEBBAA' --SuporteCecam
           ,null
           ,null
           ,null
           ,0
           ,null)
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TRANSBanco](
	[id_Banco] [int] IDENTITY(1,1) NOT NULL,
	[nr_AnoInicial] [int] NOT NULL,
	[nr_AnoFinal] [int] NOT NULL,
 CONSTRAINT [PK_TRANSBanco] PRIMARY KEY CLUSTERED 
(
	[id_Banco] 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

  insert into transbanco(nr_AnoInicial,nr_AnoFinal)
  values
  (2013,2015)
GO



alter table transbanco add nm_Cliente varchar(max) null
GO
update transbanco set nm_Cliente='PREFEITURA DO MUNICIPIO DE CECAM'
GO

alter table transpermissao add cd_PermissaoNotaEmpenho char null
GO
update transpermissao set cd_PermissaoNotaEmpenho='1'
GO