IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[F_weight_SUM]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[F_weight_SUM]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create function [dbo].[F_weight_SUM](@Contractno varchar(50))   
    returns numeric(18,3)   
    as   
       begin      
          declare  @S numeric(18,3)        
          select @S=isnull(@S,0)+convert(numeric(18,6),[weight]) from import_cargo where Contractno=@Contractno      
          return @S   
      end   
      
GO


