<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; 2005 Comparison EXCEPT operator vs. NOT IN</title>
	<atom:link href="http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sun, 12 Feb 2012 09:22:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-179866</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Mon, 17 Oct 2011 09:53:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-179866</guid>
		<description><![CDATA[You can use IF-ELSE statement in T-sql too. Refer this post http://beyondrelational.com/blogs/madhivanan/archive/2010/08/11/various-usages-of-if-else-clause-in-sql-server.aspx
Also post some sample data with eected result]]></description>
		<content:encoded><![CDATA[<p>You can use IF-ELSE statement in T-sql too. Refer this post <a href="http://beyondrelational.com/blogs/madhivanan/archive/2010/08/11/various-usages-of-if-else-clause-in-sql-server.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2010/08/11/various-usages-of-if-else-clause-in-sql-server.aspx</a><br />
Also post some sample data with eected result</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Somabrata Roy</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-179071</link>
		<dc:creator><![CDATA[Somabrata Roy]]></dc:creator>
		<pubDate>Sat, 15 Oct 2011 02:35:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-179071</guid>
		<description><![CDATA[I have a problem , i need to put multiple conditions added with OR operator inside a conditional statement like we  do in the common programming language like

if( a==&quot;2&quot; &#124;&#124; b==&quot;3&quot;)
 {

 }
else 
{

}

i want the same in T-SQL  , can you help me !!]]></description>
		<content:encoded><![CDATA[<p>I have a problem , i need to put multiple conditions added with OR operator inside a conditional statement like we  do in the common programming language like</p>
<p>if( a==&#8221;2&#8243; || b==&#8221;3&#8243;)<br />
 {</p>
<p> }<br />
else<br />
{</p>
<p>}</p>
<p>i want the same in T-SQL  , can you help me !!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raghav</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-175143</link>
		<dc:creator><![CDATA[Raghav]]></dc:creator>
		<pubDate>Tue, 04 Oct 2011 19:35:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-175143</guid>
		<description><![CDATA[Nice share]]></description>
		<content:encoded><![CDATA[<p>Nice share</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ashwani</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-155633</link>
		<dc:creator><![CDATA[ashwani]]></dc:creator>
		<pubDate>Wed, 10 Aug 2011 04:54:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-155633</guid>
		<description><![CDATA[You can use this :
select classID , TeacherID, max(startDate) from tablename group by classID , TeacherID]]></description>
		<content:encoded><![CDATA[<p>You can use this :<br />
select classID , TeacherID, max(startDate) from tablename group by classID , TeacherID</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-116033</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 04 Feb 2011 11:50:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-116033</guid>
		<description><![CDATA[The select statement should be

select * from tb_xxx where &#039;,&#039;+@ZoneCode+&#039;,&#039; like &#039;%,&#039;+cast(ZoneCode as varchar(10))+&#039;,%&#039; and id=@id]]></description>
		<content:encoded><![CDATA[<p>The select statement should be</p>
<p>select * from tb_xxx where &#8216;,&#8217;+@ZoneCode+&#8217;,&#8217; like &#8216;%,&#8217;+cast(ZoneCode as varchar(10))+&#8217;,%&#8217; and id=@id</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rochelle Kerr</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-115757</link>
		<dc:creator><![CDATA[Rochelle Kerr]]></dc:creator>
		<pubDate>Thu, 03 Feb 2011 04:21:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-115757</guid>
		<description><![CDATA[Thanks for this - I&#039;ve spent ages working out why my NOT IN returns inconsistent results - there were NULLs in my list!]]></description>
		<content:encoded><![CDATA[<p>Thanks for this &#8211; I&#8217;ve spent ages working out why my NOT IN returns inconsistent results &#8211; there were NULLs in my list!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Saidi Reddy</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-115392</link>
		<dc:creator><![CDATA[Saidi Reddy]]></dc:creator>
		<pubDate>Mon, 31 Jan 2011 16:12:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-115392</guid>
		<description><![CDATA[Hello Sir,

ALTER PROCEDURE [dbo].[Select_Data_zonetext]
@ZoneCode varchar(200),
@id bigint	 

AS
BEGIN
	SET NOCOUNT ON;

select * from tb_xxx where ZoneCode IN(@ZoneCode) and id=@id
END


the above sample stored procedure not shows any error but not retrieve required information.. please help me about this . thanks in advance]]></description>
		<content:encoded><![CDATA[<p>Hello Sir,</p>
<p>ALTER PROCEDURE [dbo].[Select_Data_zonetext]<br />
@ZoneCode varchar(200),<br />
@id bigint	 </p>
<p>AS<br />
BEGIN<br />
	SET NOCOUNT ON;</p>
<p>select * from tb_xxx where ZoneCode IN(@ZoneCode) and id=@id<br />
END</p>
<p>the above sample stored procedure not shows any error but not retrieve required information.. please help me about this . thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sushil</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-83804</link>
		<dc:creator><![CDATA[Sushil]]></dc:creator>
		<pubDate>Thu, 12 Aug 2010 06:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-83804</guid>
		<description><![CDATA[Hi all,

I want to compare two tables from one databases,
how do i compare both the tables,such that.when compared with table&#039;s columns if any records of column is updated in the either of two table&#039; columns,it should return me updated records.
(hints Table1 is old and Table2 to is new updated one and columns are same name as well as data type)

please help me.]]></description>
		<content:encoded><![CDATA[<p>Hi all,</p>
<p>I want to compare two tables from one databases,<br />
how do i compare both the tables,such that.when compared with table&#8217;s columns if any records of column is updated in the either of two table&#8217; columns,it should return me updated records.<br />
(hints Table1 is old and Table2 to is new updated one and columns are same name as well as data type)</p>
<p>please help me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anup</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-78198</link>
		<dc:creator><![CDATA[Anup]]></dc:creator>
		<pubDate>Tue, 29 Jun 2010 21:43:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-78198</guid>
		<description><![CDATA[What should i do if i want to return only the columns that do not match for 2 tables ?

Any help is appreciated.]]></description>
		<content:encoded><![CDATA[<p>What should i do if i want to return only the columns that do not match for 2 tables ?</p>
<p>Any help is appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fatih Doğanay</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-76179</link>
		<dc:creator><![CDATA[Fatih Doğanay]]></dc:creator>
		<pubDate>Mon, 14 Jun 2010 13:52:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-76179</guid>
		<description><![CDATA[Hi;
any opinion about why the first query returns data but the second and third query not return data?

select 1 where 1 in (null, 1, 2, 3);
select 1 where 10 not in (null, 1, 2, 3);
select 1 where not 10 in (null, 1, 2, 3);]]></description>
		<content:encoded><![CDATA[<p>Hi;<br />
any opinion about why the first query returns data but the second and third query not return data?</p>
<p>select 1 where 1 in (null, 1, 2, 3);<br />
select 1 where 10 not in (null, 1, 2, 3);<br />
select 1 where not 10 in (null, 1, 2, 3);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: satish</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-74337</link>
		<dc:creator><![CDATA[satish]]></dc:creator>
		<pubDate>Wed, 02 Jun 2010 08:05:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-74337</guid>
		<description><![CDATA[--
how to use IN Operater in sQl procedure

tel if u can....................

this is query??????????]]></description>
		<content:encoded><![CDATA[<p>&#8211;<br />
how to use IN Operater in sQl procedure</p>
<p>tel if u can&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..</p>
<p>this is query??????????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morshed</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-63392</link>
		<dc:creator><![CDATA[Morshed]]></dc:creator>
		<pubDate>Sun, 21 Mar 2010 11:11:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-63392</guid>
		<description><![CDATA[--following except is not working 

select ad.code ,ad.description, count (di.cod_acct_no)as &quot;No of Cards&quot; from account_master d, accountinfo di, branch ad
where d.p_acct_no=di.cod_acct_no and ad.branchid=di.branchid
and di.dat_acct_open between &#039;2010-02-27 00:00:00&#039;
and &#039;2010-03-11 00:00:00&#039;
and d.iss_date between &#039;2010-02-27 00:00:00&#039;
and &#039;2010-03-11 23:59:00&#039;
and accounttypeid in (1,2,3,55)
group by ad.code, ad.description
order by ad.code, ad.description 
EXCEPT
select ad.code ,ad.description, count (di.cod_acct_no)as &quot;No of Cards&quot; from account_master d, accountinfo di, branch ad
where d.p_acct_no=di.cod_acct_no and ad.branchid=di.branchid
and di.dat_acct_open between &#039;2010-02-20 00:00:00&#039;
and &#039;2010-03-11 00:00:00&#039;
and d.iss_date between &#039;2010-02-20 00:00:00&#039;
and &#039;2010-03-11 23:59:00&#039;
and accounttypeid in (1,2,3,55)
group by ad.code, ad.description
order by ad.code, ad.description]]></description>
		<content:encoded><![CDATA[<p>&#8211;following except is not working </p>
<p>select ad.code ,ad.description, count (di.cod_acct_no)as &#8220;No of Cards&#8221; from account_master d, accountinfo di, branch ad<br />
where d.p_acct_no=di.cod_acct_no and ad.branchid=di.branchid<br />
and di.dat_acct_open between &#8217;2010-02-27 00:00:00&#8242;<br />
and &#8217;2010-03-11 00:00:00&#8242;<br />
and d.iss_date between &#8217;2010-02-27 00:00:00&#8242;<br />
and &#8217;2010-03-11 23:59:00&#8242;<br />
and accounttypeid in (1,2,3,55)<br />
group by ad.code, ad.description<br />
order by ad.code, ad.description<br />
EXCEPT<br />
select ad.code ,ad.description, count (di.cod_acct_no)as &#8220;No of Cards&#8221; from account_master d, accountinfo di, branch ad<br />
where d.p_acct_no=di.cod_acct_no and ad.branchid=di.branchid<br />
and di.dat_acct_open between &#8217;2010-02-20 00:00:00&#8242;<br />
and &#8217;2010-03-11 00:00:00&#8242;<br />
and d.iss_date between &#8217;2010-02-20 00:00:00&#8242;<br />
and &#8217;2010-03-11 23:59:00&#8242;<br />
and accounttypeid in (1,2,3,55)<br />
group by ad.code, ad.description<br />
order by ad.code, ad.description</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58294</link>
		<dc:creator><![CDATA[david]]></dc:creator>
		<pubDate>Tue, 08 Dec 2009 00:20:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58294</guid>
		<description><![CDATA[Hi Brian and Pinal

Your guys are rocks!

I like the solution such as 
SELECT
[INSTITUTION],
[CODE],
[EFF_DATE],
MAX(Col1), --solve the problem with column not group by
MAX(Col2),
MAX(Col3)
FROM
DDEF_CRS_Stage
GROUP BY
[INSTITUTION],
[CODE]
[EFF_DATE]
HAVING
COUNT(*) = 1;

The following code, I have to use table variables to solve the same problem in SQL Server.

declare @tbl table([INSTITUTION] varchar(4)
      ,[CODE] varchar(20)
      ,[EFF_DATE] datetime);

Insert into @tbl
select [INSTITUTION]
      ,[CODE]
      ,[EFF_DATE] from DDEF_CRS_Stage 
group by [INSTITUTION]
      ,[CODE]
      ,[EFF_DATE]
Having COUNT(*) &gt; 1;

select * from DDEF_CRS_Stage
EXCEPT
(
select * from DDEF_CRS_Stage
where [INSTITUTION] IN
(select [INSTITUTION] from @tbl)
AND [CODE] IN
(select [Code] from @tbl)
AND [EFF_DATE] IN
(select [EFF_DATE] from @tbl)
)

Have a fun with your guys.

David]]></description>
		<content:encoded><![CDATA[<p>Hi Brian and Pinal</p>
<p>Your guys are rocks!</p>
<p>I like the solution such as<br />
SELECT<br />
[INSTITUTION],<br />
[CODE],<br />
[EFF_DATE],<br />
MAX(Col1), &#8211;solve the problem with column not group by<br />
MAX(Col2),<br />
MAX(Col3)<br />
FROM<br />
DDEF_CRS_Stage<br />
GROUP BY<br />
[INSTITUTION],<br />
[CODE]<br />
[EFF_DATE]<br />
HAVING<br />
COUNT(*) = 1;</p>
<p>The following code, I have to use table variables to solve the same problem in SQL Server.</p>
<p>declare @tbl table([INSTITUTION] varchar(4)<br />
      ,[CODE] varchar(20)<br />
      ,[EFF_DATE] datetime);</p>
<p>Insert into @tbl<br />
select [INSTITUTION]<br />
      ,[CODE]<br />
      ,[EFF_DATE] from DDEF_CRS_Stage<br />
group by [INSTITUTION]<br />
      ,[CODE]<br />
      ,[EFF_DATE]<br />
Having COUNT(*) &gt; 1;</p>
<p>select * from DDEF_CRS_Stage<br />
EXCEPT<br />
(<br />
select * from DDEF_CRS_Stage<br />
where [INSTITUTION] IN<br />
(select [INSTITUTION] from @tbl)<br />
AND [CODE] IN<br />
(select [Code] from @tbl)<br />
AND [EFF_DATE] IN<br />
(select [EFF_DATE] from @tbl)<br />
)</p>
<p>Have a fun with your guys.</p>
<p>David</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subbarao</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58252</link>
		<dc:creator><![CDATA[Subbarao]]></dc:creator>
		<pubDate>Sun, 06 Dec 2009 18:34:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58252</guid>
		<description><![CDATA[Hi Sucharitha,

    Eevery time your are checking with only one column, &quot;building&quot;. So create a separate table with a single column. ex tblBuildingList(strBuilding VARCHAR(100).

INSERT INTO tblBuildingList(strBuilding) VALUES(%School%)
INSERT INTO tblBuildingList(strBuilding) VALUES(%Church%)
.......


select Building from yourTableName tbl
INNER JOIN tblBuildingList bld ON 
tbl.Building NOT LIKE bld.strBuilding 

I think it ll solve your problem, bcz no need to change the query when ever adding new list. just insert the list value into the tblBuildingList.

Thanks]]></description>
		<content:encoded><![CDATA[<p>Hi Sucharitha,</p>
<p>    Eevery time your are checking with only one column, &#8220;building&#8221;. So create a separate table with a single column. ex tblBuildingList(strBuilding VARCHAR(100).</p>
<p>INSERT INTO tblBuildingList(strBuilding) VALUES(%School%)<br />
INSERT INTO tblBuildingList(strBuilding) VALUES(%Church%)<br />
&#8230;&#8230;.</p>
<p>select Building from yourTableName tbl<br />
INNER JOIN tblBuildingList bld ON<br />
tbl.Building NOT LIKE bld.strBuilding </p>
<p>I think it ll solve your problem, bcz no need to change the query when ever adding new list. just insert the list value into the tblBuildingList.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58199</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Fri, 04 Dec 2009 14:39:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58199</guid>
		<description><![CDATA[@david

Like Pinal said, make it an EXISTS. I&#039;d like to add, that the NOT IN (or NOT EXISTS) can be IN (or EXISTS) as it can be checked to = 1 instead of being NOT &gt; 1.

However, the best of all is to use neither. Since the query limits the results to one record per group (as any groups with multiple records are excluded) using aggregates will have no effect on the results:

SELECT
		[INSTITUTION],
		[CODE],
		[EFF_DATE],
		MAX(Col1),
		MAX(Col2),
		MAX(Col3)
FROM
		DDEF_CRS_Stage
GROUP BY
		[INSTITUTION],
		[CODE]
		[EFF_DATE]
 HAVING
		COUNT(*) = 1;]]></description>
		<content:encoded><![CDATA[<p>@david</p>
<p>Like Pinal said, make it an EXISTS. I&#8217;d like to add, that the NOT IN (or NOT EXISTS) can be IN (or EXISTS) as it can be checked to = 1 instead of being NOT &gt; 1.</p>
<p>However, the best of all is to use neither. Since the query limits the results to one record per group (as any groups with multiple records are excluded) using aggregates will have no effect on the results:</p>
<p>SELECT<br />
		[INSTITUTION],<br />
		[CODE],<br />
		[EFF_DATE],<br />
		MAX(Col1),<br />
		MAX(Col2),<br />
		MAX(Col3)<br />
FROM<br />
		DDEF_CRS_Stage<br />
GROUP BY<br />
		[INSTITUTION],<br />
		[CODE]<br />
		[EFF_DATE]<br />
 HAVING<br />
		COUNT(*) = 1;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58193</link>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Fri, 04 Dec 2009 11:06:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58193</guid>
		<description><![CDATA[Hello David,

Multiple columns in single where clause is not supported in SQL Server. You have to write a saperate NOT IN clause fora each column. 
Another better way to perform the same thing is using  NOT EXISTS clause where you would not have to write saperate subquery for each column. 

Kind Regards,
Pinal Dave]]></description>
		<content:encoded><![CDATA[<p>Hello David,</p>
<p>Multiple columns in single where clause is not supported in SQL Server. You have to write a saperate NOT IN clause fora each column.<br />
Another better way to perform the same thing is using  NOT EXISTS clause where you would not have to write saperate subquery for each column. </p>
<p>Kind Regards,<br />
Pinal Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58156</link>
		<dc:creator><![CDATA[david]]></dc:creator>
		<pubDate>Thu, 03 Dec 2009 17:59:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-58156</guid>
		<description><![CDATA[Is there script in SQL SERVER to support multi fields like Oracle in &quot;WHERE (col1,col2) NOT IN(...)&quot; ?

Here is the script I want to run bot not support in SQL Server. It works in Oracle. [INSTITUTION],[CODE] ,[EFF_DATE] are composite primary key.

SELECT *
from DDEF_CRS_Stage
where ([INSTITUTION]
      ,[CODE]
      ,[EFF_DATE])
NOT IN
(
select [INSTITUTION]
      ,[CODE]
      ,[EFF_DATE] from DDEF_CRS_Stage
group by [INSTITUTION]
      ,[CODE]
      ,[EFF_DATE]
Having COUNT(*) &gt; 1
)

Thank you.]]></description>
		<content:encoded><![CDATA[<p>Is there script in SQL SERVER to support multi fields like Oracle in &#8220;WHERE (col1,col2) NOT IN(&#8230;)&#8221; ?</p>
<p>Here is the script I want to run bot not support in SQL Server. It works in Oracle. [INSTITUTION],[CODE] ,[EFF_DATE] are composite primary key.</p>
<p>SELECT *<br />
from DDEF_CRS_Stage<br />
where ([INSTITUTION]<br />
      ,[CODE]<br />
      ,[EFF_DATE])<br />
NOT IN<br />
(<br />
select [INSTITUTION]<br />
      ,[CODE]<br />
      ,[EFF_DATE] from DDEF_CRS_Stage<br />
group by [INSTITUTION]<br />
      ,[CODE]<br />
      ,[EFF_DATE]<br />
Having COUNT(*) &gt; 1<br />
)</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57124</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Wed, 28 Oct 2009 23:05:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57124</guid>
		<description><![CDATA[Thanks Brian,

Very good point!]]></description>
		<content:encoded><![CDATA[<p>Thanks Brian,</p>
<p>Very good point!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Waseem</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57093</link>
		<dc:creator><![CDATA[Waseem]]></dc:creator>
		<pubDate>Wed, 28 Oct 2009 05:50:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57093</guid>
		<description><![CDATA[Thanks for sharing the needed information!]]></description>
		<content:encoded><![CDATA[<p>Thanks for sharing the needed information!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57084</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Tue, 27 Oct 2009 17:58:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57084</guid>
		<description><![CDATA[@Sucharitha

I don&#039;t know of any. (Though i am not an expert.)

It seems that every field would need to be scanned, resulting in a full table scan. Indexing won&#039;t even help because it would be indexing off the description and not the part that you want.]]></description>
		<content:encoded><![CDATA[<p>@Sucharitha</p>
<p>I don&#8217;t know of any. (Though i am not an expert.)</p>
<p>It seems that every field would need to be scanned, resulting in a full table scan. Indexing won&#8217;t even help because it would be indexing off the description and not the part that you want.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sucharitha</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57081</link>
		<dc:creator><![CDATA[Sucharitha]]></dc:creator>
		<pubDate>Tue, 27 Oct 2009 16:27:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57081</guid>
		<description><![CDATA[Hello Brian,

Thank you for the suggestion which was obviously in my mind. I am new into the team and company, and the application has been built and stabilised. I need to study it better before i make any changes to the DB.
But at this time,  I have been asked to get a quick report where I need to filter on something like this. Is there any other quick solution running in your mind?]]></description>
		<content:encoded><![CDATA[<p>Hello Brian,</p>
<p>Thank you for the suggestion which was obviously in my mind. I am new into the team and company, and the application has been built and stabilised. I need to study it better before i make any changes to the DB.<br />
But at this time,  I have been asked to get a quick report where I need to filter on something like this. Is there any other quick solution running in your mind?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57077</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Tue, 27 Oct 2009 14:15:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57077</guid>
		<description><![CDATA[@Sucharitha

Ideally there should be a type field instead of searching a name for the type.

If there is a list that will be managed daily, perhaps another TABLE would be best. Then the query could use a join and not have to change.]]></description>
		<content:encoded><![CDATA[<p>@Sucharitha</p>
<p>Ideally there should be a type field instead of searching a name for the type.</p>
<p>If there is a list that will be managed daily, perhaps another TABLE would be best. Then the query could use a join and not have to change.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sucharitha</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57067</link>
		<dc:creator><![CDATA[Sucharitha]]></dc:creator>
		<pubDate>Tue, 27 Oct 2009 12:58:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-57067</guid>
		<description><![CDATA[Can any one help me with such a query below.

SELECT DISTINCT Building WHERE Building IS NOT NULL
		AND Building NOT LIKE &#039;%School%&#039;
		AND Building NOT LIKE &#039;%Church%&#039;
		AND Building NOT LIKE &#039;%Rectory%&#039;
		AND Building NOT LIKE &#039;%Public House%&#039;
		AND Building NOT LIKE &#039;%Retail Park%&#039;
		AND Building NOT LIKE &#039;%Railway Station%&#039;
		AND Building NOT LIKE &#039;%Post Office%&#039;
		AND Building NOT LIKE &#039;%Court%&#039;
		AND Building NOT LIKE &#039;%Floor%&#039;
		AND Building NOT LIKE &#039;%Flat%&#039;
		AND Building NOT LIKE &#039;%Former%&#039;
		AND Building NOT LIKE &#039;%Lodge%&#039;

basically as per my requirement, the list in the not like might increase daily, I dont find the query good with the whole list as above. Is there a way I can avoid it.

Please suggest.]]></description>
		<content:encoded><![CDATA[<p>Can any one help me with such a query below.</p>
<p>SELECT DISTINCT Building WHERE Building IS NOT NULL<br />
		AND Building NOT LIKE &#8216;%School%&#8217;<br />
		AND Building NOT LIKE &#8216;%Church%&#8217;<br />
		AND Building NOT LIKE &#8216;%Rectory%&#8217;<br />
		AND Building NOT LIKE &#8216;%Public House%&#8217;<br />
		AND Building NOT LIKE &#8216;%Retail Park%&#8217;<br />
		AND Building NOT LIKE &#8216;%Railway Station%&#8217;<br />
		AND Building NOT LIKE &#8216;%Post Office%&#8217;<br />
		AND Building NOT LIKE &#8216;%Court%&#8217;<br />
		AND Building NOT LIKE &#8216;%Floor%&#8217;<br />
		AND Building NOT LIKE &#8216;%Flat%&#8217;<br />
		AND Building NOT LIKE &#8216;%Former%&#8217;<br />
		AND Building NOT LIKE &#8216;%Lodge%&#8217;</p>
<p>basically as per my requirement, the list in the not like might increase daily, I dont find the query good with the whole list as above. Is there a way I can avoid it.</p>
<p>Please suggest.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shrikant Patil</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-55158</link>
		<dc:creator><![CDATA[Shrikant Patil]]></dc:creator>
		<pubDate>Mon, 24 Aug 2009 12:25:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-55158</guid>
		<description><![CDATA[Sorry i forgot to add where value IN  in the above post . In actual &#039;m using the same query u  have return it works for small number of rows also . but when i have 90000 rows as i said above it doesnt work the way it should .]]></description>
		<content:encoded><![CDATA[<p>Sorry i forgot to add where value IN  in the above post . In actual &#8216;m using the same query u  have return it works for small number of rows also . but when i have 90000 rows as i said above it doesnt work the way it should .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-55127</link>
		<dc:creator><![CDATA[Imran Mohammed]]></dc:creator>
		<pubDate>Sun, 23 Aug 2009 03:54:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/22/sql-server-2005-comparison-except-operator-vs-not-in/#comment-55127</guid>
		<description><![CDATA[@Shrikanth Patil.

Your first select statement is not valid. I am not sure if it could ever execute, because you are not specific about what to be search for NOT IN. 

Anyways below is a working example, consider this example and let us know if this is what you were expecting.

Example Script : 

create table #die_domain_log ( Value int identity , source_flag int , target_flag int, log_id int )

insert into #die_domain_log values ( 1, NULL , 103)
insert into #die_domain_log values ( 1, NULL , 103)
insert into #die_domain_log values ( 1, NULL , 103)
insert into #die_domain_log values ( 1, NULL , 103)
insert into #die_domain_log values ( 1, NULL , 103)

insert into #die_domain_log values (  NULL , 1, 103)
insert into #die_domain_log values (  NULL , 1, 103)
insert into #die_domain_log values (  NULL , 1, 103)
insert into #die_domain_log values (  NULL , 1, 103)
insert into #die_domain_log values (  NULL , 1, 103)


Select * from #die_domain_log 


-- Here you need to be specific what to search for NOT IN, I have include Value as a search criteria for NOT IN.

SELECT    value 
FROM       #die_domain_log 
WHERE    source_flag =1 
AND         log_id=103
AND         value 
NOT IN 
( 
SELECT     i.value 
FROM        #die_domain_log i 
WHERE     i.target_flag =1 
AND          i.log_id=103 
)

-- OR ( below is same as you posted)

SELECT value FROM #die_domain_log WHERE source_flag =1 AND log_id=103
EXCEPT
SELECT i.value FROM #die_domain_log i WHERE i.target_flag =1 AND i.log_id=103

~ IM.]]></description>
		<content:encoded><![CDATA[<p>@Shrikanth Patil.</p>
<p>Your first select statement is not valid. I am not sure if it could ever execute, because you are not specific about what to be search for NOT IN. </p>
<p>Anyways below is a working example, consider this example and let us know if this is what you were expecting.</p>
<p>Example Script : </p>
<p>create table #die_domain_log ( Value int identity , source_flag int , target_flag int, log_id int )</p>
<p>insert into #die_domain_log values ( 1, NULL , 103)<br />
insert into #die_domain_log values ( 1, NULL , 103)<br />
insert into #die_domain_log values ( 1, NULL , 103)<br />
insert into #die_domain_log values ( 1, NULL , 103)<br />
insert into #die_domain_log values ( 1, NULL , 103)</p>
<p>insert into #die_domain_log values (  NULL , 1, 103)<br />
insert into #die_domain_log values (  NULL , 1, 103)<br />
insert into #die_domain_log values (  NULL , 1, 103)<br />
insert into #die_domain_log values (  NULL , 1, 103)<br />
insert into #die_domain_log values (  NULL , 1, 103)</p>
<p>Select * from #die_domain_log </p>
<p>&#8211; Here you need to be specific what to search for NOT IN, I have include Value as a search criteria for NOT IN.</p>
<p>SELECT    value<br />
FROM       #die_domain_log<br />
WHERE    source_flag =1<br />
AND         log_id=103<br />
AND         value<br />
NOT IN<br />
(<br />
SELECT     i.value<br />
FROM        #die_domain_log i<br />
WHERE     i.target_flag =1<br />
AND          i.log_id=103<br />
)</p>
<p>&#8211; OR ( below is same as you posted)</p>
<p>SELECT value FROM #die_domain_log WHERE source_flag =1 AND log_id=103<br />
EXCEPT<br />
SELECT i.value FROM #die_domain_log i WHERE i.target_flag =1 AND i.log_id=103</p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

