SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_CustWiseSalesSummary] @CustomerCode as varchar(50), @FromDate datetime, @ToDate datetime AS begin SELECT EntryDate, BillType,Commision, InvNo, GrossAmount, LessAmount, AddLess, ISNULL(VATTOTAL,0)+GrossAmount - (LessAmount + AddLess+Commision) AS NetAmount,ISNULL(VATTOTAL,0)as VATTOTAL,customercode,CustomerName FROM Invoice WHERE SR = 'Sales' and --CustomerCode=@CustomerCode CustomerCode=isnull(@CustomerCode,customercode) and Invoice.EntryDate between @FromDate and @ToDate AND ISNULL(Deleted,'N')='N' end