title: Stored procedure doesn't return any row but same query returns proper data
body: <p>Here is my stored procedure:</p>
  
  <pre><code>CREATE PROC [SPmainReport]
  @startDate date = null,
  @endDate date = null,
  @customerName varchar = null,
  
  AS
  SELECT Distinct
      VI.Code as CustomerCode, VI.Name as CustomerName, VI.Area as CustomerArea, VI.[Address] as [address], CP.ProductName as ProductName, CP.ProductQuantity as Quantity
  from 
  VendorTrading VT inner join CustomerProducts CP on VT.Id = CP.VendorTradingId inner join VendorInfo VI on VT.VendorId = VI.Id
  where
   (VT.Tradedate between isnull(@startDate,VT.Tradedate) and isnull(@endDate,VT.Tradedate))
   and VI.Name = ISNULL(@customerName, VI.Name)
  </code></pre>
  
  <p>On execution it doesn't return any value but if I execute this query:</p>
  
  <pre><code>    SELECT Distinct
      VI.Code as CustomerCode, VI.Name as CustomerName, VI.Area as CustomerArea, VI.[Address] as [address], CP.ProductName as ProductName, CP.ProductQuantity as Quantity
  from 
  VendorTrading VT inner join CustomerProducts CP on VT.Id = CP.VendorTradingId inner join VendorInfo VI on VT.VendorId = VI.Id
  where
   (VT.Tradedate between isnull(@startDate,VT.Tradedate) and isnull(@endDate,VT.Tradedate))
   and VI.Name = ISNULL('John', VI.Name)
  </code></pre>
  
  <p>It return exactly required data. I am totally confused why it is happening. There is no difference at all. I am making sure scripts are running on same database and it also contains perfect data. here is SP execution script:</p>
  
  <pre><code>USE [E:\SANDWICH3\ABC\BIN\DEBUG\DATABASE\ABC.MDF]
  GO
  
  DECLARE @return_value Int
  
  EXEC    @return_value = [dbo].[SPmainReport]
      @startDate = '2015-12-25',
      @endDate = '2015-12-25',
      @customerName = N'John'
  
  SELECT  @return_value as 'Return Value'
  
  GO
  </code></pre>
  
  <p>One more strange I have noticed is that If I modify this SP and limit conditions with just DATES, not name. It works fine then.
  I am working on Visual Studio 2013 Interface of SQL server. Not management studio (In case it does matter)</p>