

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='cat_listaPrecio' and column_name = 'id_moneda' )
begin
alter table [cat_listaPrecio] add [id_moneda] int not NULL DEFAULT 0
end

GO
IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[cat_listaPrecio]') AND object_id = OBJECT_ID(N'[dbo].[fk_cat_listaPrecio_id_moneda]')  )
ALTER TABLE [cat_listaPrecio] ADD CONSTRAINT
	[fk_cat_listaPrecio_id_moneda] FOREIGN KEY
	([id_moneda]) REFERENCES [gen_moneda]	(id)
 
ALTER TABLE [dbo].[cat_listaPrecio] CHECK CONSTRAINT [fk_cat_listaPrecio_id_moneda]
GO


IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='cat_listaPrecio'
      AND [columna]='id_moneda' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('cat_listaPrecio' ,'id_moneda',1 ,5 ,1 ,'int' ,0 ,100)
END

