if not exists (select 1 from [_tablas] where [tabla] = 'equ_analisisFalla')
begin
	INSERT INTO [dbo].[_tablas]
			   ([tabla]
			   ,[esMultiempresa]
			   ,[duplicar]
			   ,[eliminarIntermedias])
		 VALUES
			   ('equ_analisisFalla'
			   ,1
			   ,0
			   ,0)
end
GO

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'id')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'id', 1, 1, 0, 'int', NULL, NULL, NULL, 0, 1, 0)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'uid')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'uid', 1, 1, 0, 'varchar', NULL, 500, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'eid')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'eid', 1, 1, 0, 'varchar', NULL, 50, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'id_usuario_modifico')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'id_usuario_modifico', 1, 1, 0, 'int', '((0))', NULL, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'id_usuario_creo')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'id_usuario_creo', 1, 1, 0, 'int', '((0))', NULL, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'fechaModificacion')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'fechaModificacion', 0, 0, 0, 'datetime', '(getdate())', NULL, NULL, 0, 1, 0)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'fechaCreacion')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'fechaCreacion', 0, 0, 0, 'smalldatetime', '(getdate())', NULL, NULL, 0, 1, 0)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'active')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'active', 1, 1, 0, 'bit', '((1))', NULL, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'analisisFalla')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'analisisFalla', 1, 1, 0, 'varchar', NULL, 300, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'analisisFalla_codigo')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'analisisFalla_codigo', 1, 1, 0, 'varchar', NULL, 100, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'id_catalogo.equipo')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'id_catalogo.equipo', 1, 1, 0, 'int', '((0))', NULL, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'id_falla')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'id_falla', 1, 1, 0, 'int', '((0))', NULL, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'id_falla_causa')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'id_falla_causa', 1, 1, 0, 'int', '((0))', NULL, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'id_falla_efecto')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'id_falla_efecto', 1, 1, 0, 'int', '((0))', NULL, NULL, 0, 1, 1)
end
go

if not exists (select 1 from [dbo].[_columnas] where [tabla] = 'equ_analisisFalla' and [columna] = 'id_falla_solucion')
begin
	INSERT INTO [dbo].[_columnas]
			   ([tabla]
			   ,[columna]
			   ,[mostrarEnGrilla]
			   ,[ordenGrilla]
			   ,[requerido]
			   ,[tipo]
			   ,[defecto]	
			   ,[tamano]
			   ,[dependiente]
			   ,[id_seccionAtributo]
			   ,[mostrarEnAPI]
			   ,[ordenEdicion])
		 VALUES
			   ('equ_analisisFalla', 'id_falla_solucion', 1, 1, 0, 'int', '((0))', NULL, NULL, 0, 1, 1)
end
go
