﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / null checking / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 00:25:02 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: null checking</title><link>http://www.sqlservercentral.com/Forums/Topic1369651-1292-1.aspx</link><description>[quote][b]shilpaprele (10/8/2012)[/b][hr]I have one procedure with parameter @P.  If @p= null &amp; table abc has many rows with col1 =  null, then following select does not reurn the values select  *from abcwhere col1 = @Pwhat should be correct the syntax(  do not wan tto use set ansi null on/off).[/quote]The correct way, to return records, would be:[code="sql"]select  *from abcwhere col1 = @P OR (@P IS NULL AND col1 IS NULL)[/code]Using, ISNULL function on a column would stop this query to SARGable if you have an index on Col1Saying all the above, you should really read Gail Shaw's paper on catch-all-queries :[url]http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/[/url]</description><pubDate>Mon, 08 Oct 2012 07:24:49 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>RE: null checking</title><link>http://www.sqlservercentral.com/Forums/Topic1369651-1292-1.aspx</link><description>Hi, sorry I forget about passing parameters..chk this one, hope this one helps -IF (@p = 'NULL' OR @p IS NULL)BEGIN	SELECT * FROM abc WHERE name1 IS NULLENDELSEBEGIN	SELECT * FROM abc WHERE name1 LIKE @pEND</description><pubDate>Mon, 08 Oct 2012 05:52:14 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: null checking</title><link>http://www.sqlservercentral.com/Forums/Topic1369651-1292-1.aspx</link><description>Dear Valued memberthis is not taking care of the null value in parameter</description><pubDate>Mon, 08 Oct 2012 05:16:17 GMT</pubDate><dc:creator>Krishna1</dc:creator></item><item><title>RE: null checking</title><link>http://www.sqlservercentral.com/Forums/Topic1369651-1292-1.aspx</link><description>select * from abcwhere column_name IS NULL</description><pubDate>Mon, 08 Oct 2012 04:48:37 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: null checking</title><link>http://www.sqlservercentral.com/Forums/Topic1369651-1292-1.aspx</link><description>Check this:select *from abcwhere ISNUll(col1,'') = ISNULL(@P,'')</description><pubDate>Mon, 08 Oct 2012 02:42:08 GMT</pubDate><dc:creator>Bhumika Jawanjal</dc:creator></item><item><title>RE: null checking</title><link>http://www.sqlservercentral.com/Forums/Topic1369651-1292-1.aspx</link><description>[quote][b]shilpaprele (10/8/2012)[/b][hr]I have one procedure with parameter @P.  If @p= null &amp; table abc has many rows with col1 =  null, then following select does not reurn the values select  *from abcwhere col1 = @Pwhat should be correct the syntax(  do not wan tto use set ansi null on/off).[/quote][code="sql"]select *from abcwhere col1 = @P 	OR (@P IS NULL AND col1 IS NULL)[/code]</description><pubDate>Mon, 08 Oct 2012 02:37:33 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>null checking</title><link>http://www.sqlservercentral.com/Forums/Topic1369651-1292-1.aspx</link><description>I have one procedure with parameter @P.  If @p= null &amp; table abc has many rows with col1 =  null, then following select does not reurn the values select  *from abcwhere col1 = @Pwhat should be correct the syntax(  do not wan tto use set ansi null on/off).</description><pubDate>Mon, 08 Oct 2012 01:45:34 GMT</pubDate><dc:creator>Krishna1</dc:creator></item></channel></rss>