SQL server SP : @Param 's with sometime NULL values

Posted by openidsujoy on Stack Overflow See other posts from Stack Overflow or by openidsujoy
Published on 2009-12-03T09:16:03Z Indexed on 2010/05/03 3:08 UTC
Read the original article Hit count: 273

I am very new to SQL Server Stored Procedures, I am trying to create a SP that will give return a list of records in a table by filter via StartDate and EndDate , but there will be 'View All' Option so sometime those @Param might not contain any values.

Currently my SP is Like

CREATE PROCEDURE [dbo].[spGetBonusRun]
 (
@StartDate as DATETIME,
@EndDate as DATETIME
 )
AS

SELECT [Id]
  ,[StartDateTime]
  ,[EndDate]
  ,[Status]
FROM [Valt].[dbo].[BonusRun]
WHERE StartDateTime <= @StartDate AND EndDate >= @EndDate

How to active that ?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about stored-procedures