if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Less_Exp]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[Less_Exp]

if Exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AddExpirationOfGoods]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
Drop Procedure [dbo].[AddExpirationOfGoods]


if Exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Sp_Auto_OURow_Factor]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
Drop Procedure [dbo].[Sp_Auto_OURow_Factor]

Declare @Id Int                               
Select @Id = Id From sysobjects Where Name = 'AnbarId'
if not Exists(SELECT * FROM syscolumns WHERE id = @Id and Name = 'NatureWarehouse')
  Alter Table dbo.AnbarId Add NatureWarehouse tinyInt DEFAULT(0)



