declare @table_name nvarchar(64)
declare @column_name nvarchar(64)

set @table_name = 'pr_products_branches'
set @column_name = 'prdb_monthly_payment_code' 

IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE  TABLE_NAME=@table_name AND COLUMN_NAME=@column_name )
begin
	delete from md_dictionaries_fields where dictf_table_name = @table_name and dictf_field_name = @column_name

	delete from md_fields where fld_table_name = @table_name and fld_field_name = @column_name

	exec p_sys_drop_column @table_name, @column_name
end
