0 Comments

This examples uses the Microsoft SQL Server 2008 example database AdventureWorks (http://msftdbprodsamples.codeplex.com/)

If you want to return all rows of a table when a parameter is null, use the TSQL function isnull:

declare @productModelID as int
set @productModelID = null


select
    p.*
from
    Production.Product p
where
    isnull(@productModelID, p.ProductModelID) = p.ProductModelID
order by p.ProductID

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Fix favicon error

0 Comments

When there is no favicon.ico in the root of your…

What I learned today

0 Comments

Microsoft Office 2016 Installed Microsoft Office 2016 and I’m impressed…