<?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: SQLAuthority News &#8211; Interesting Read &#8211; Using A SQL JOIN In A SQL UPDATE/Delete Statement &#8211; Ben Nadel</title>
	<atom:link href="http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 23 May 2013 14:22:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jignesh Shah</title>
		<link>http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-73616</link>
		<dc:creator><![CDATA[Jignesh Shah]]></dc:creator>
		<pubDate>Fri, 28 May 2010 05:13:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-73616</guid>
		<description><![CDATA[Hi ,

I want to update a table based on distinct data combination of 3 columns. Let me explain .

Columns in the table 

ENQUIRY_NO,MODIFY_BY  ,ENQ_DATE  ,MAIN_STATUS ,LINE_STATUS


Now i want to update the MAIN_STATUS of the table based on COMBINATION OF DISTINCT ENQRUIY_NO,MODIFY_BY,ENQ_DATE and with HARDCODED condition of LINE_STATUS.

If even a Single LINE_STATUS is in &quot;Order&quot; make the MAIN_STATUS as &quot;Order&quot; for all the lines having same (ENQUIRY_NO,MODIFY_BY  ,ENQ_DATE)

and after that next step is ---
If even a Single LINE_STATUS is in &quot;Working&quot; make the MAIN_STATUS as &quot;Working&quot; for all the lines having same (ENQUIRY_NO,MODIFY_BY  ,ENQ_DATE)

basically i want to achive it with 2 simple t-SQL UPDATE statements and not through lenghty procedure.....

Could you please help  me....

Any help would be highly appreciated

Thanks,
Jignesh]]></description>
		<content:encoded><![CDATA[<p>Hi ,</p>
<p>I want to update a table based on distinct data combination of 3 columns. Let me explain .</p>
<p>Columns in the table </p>
<p>ENQUIRY_NO,MODIFY_BY  ,ENQ_DATE  ,MAIN_STATUS ,LINE_STATUS</p>
<p>Now i want to update the MAIN_STATUS of the table based on COMBINATION OF DISTINCT ENQRUIY_NO,MODIFY_BY,ENQ_DATE and with HARDCODED condition of LINE_STATUS.</p>
<p>If even a Single LINE_STATUS is in &#8220;Order&#8221; make the MAIN_STATUS as &#8220;Order&#8221; for all the lines having same (ENQUIRY_NO,MODIFY_BY  ,ENQ_DATE)</p>
<p>and after that next step is &#8212;<br />
If even a Single LINE_STATUS is in &#8220;Working&#8221; make the MAIN_STATUS as &#8220;Working&#8221; for all the lines having same (ENQUIRY_NO,MODIFY_BY  ,ENQ_DATE)</p>
<p>basically i want to achive it with 2 simple t-SQL UPDATE statements and not through lenghty procedure&#8230;..</p>
<p>Could you please help  me&#8230;.</p>
<p>Any help would be highly appreciated</p>
<p>Thanks,<br />
Jignesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tejasnshah</title>
		<link>http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-47818</link>
		<dc:creator><![CDATA[tejasnshah]]></dc:creator>
		<pubDate>Mon, 02 Mar 2009 06:40:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-47818</guid>
		<description><![CDATA[Hi Dale,

try this: SET @MYSQL = ‘DELETE &#039; + @TABLENAME + &#039; FROM ‘ + @TABLENAME + @MYJOINCONDITION + ‘ WHERE ‘ + @TABLE_FK + ‘= ‘ + CAST(@DBID AS NVARCHAR)


Thanks,

Tejas]]></description>
		<content:encoded><![CDATA[<p>Hi Dale,</p>
<p>try this: SET @MYSQL = ‘DELETE &#8216; + @TABLENAME + &#8216; FROM ‘ + @TABLENAME + @MYJOINCONDITION + ‘ WHERE ‘ + @TABLE_FK + ‘= ‘ + CAST(@DBID AS NVARCHAR)</p>
<p>Thanks,</p>
<p>Tejas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dale</title>
		<link>http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-47814</link>
		<dc:creator><![CDATA[Dale]]></dc:creator>
		<pubDate>Mon, 02 Mar 2009 05:40:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-47814</guid>
		<description><![CDATA[Hello Dave,

I have a dynamic sql statement that creates

DELETE FROM [dbo].[Indexes] I INNER JOIN [dbo].[Tables] T ON [I].[TableID_FK] = [T].[TableID_PK]  WHERE [T].[DatabaseID_FK]= 308


The code that created ths statement is: 
  SET @MYSQL = &#039;DELETE FROM &#039; + @TABLENAME + @MYJOINCONDITION + &#039; WHERE &#039; + @TABLE_FK + &#039;= &#039; + CAST(@DBID AS NVARCHAR)

The error SQL is returning is:  Incorrect syntax near &#039;I&#039;.

Maybe it&#039;s just late and my eyes are tired, but I&#039;m having trouble seing where the error is. Of course, you can tell that I&#039;m using a join inside the delete statement. 

I&#039;m looking to delete all records from the index table that reference a table that is inside a database that is also being deleted.

As this script continues to attempt to delete the database this error is returned: Msg 547, Level 16, State 0, Line 212
The DELETE statement conflicted with the REFERENCE constraint &quot;FK_Databases_SQLServer&quot;. The conflict occurred in database &quot;MyTestDatabase&quot;, table &quot;dbo.Databases&quot;, column &#039;DBServerID_FK&#039;.

Thanks for any time spent in reviewing this design.

Dale]]></description>
		<content:encoded><![CDATA[<p>Hello Dave,</p>
<p>I have a dynamic sql statement that creates</p>
<p>DELETE FROM [dbo].[Indexes] I INNER JOIN [dbo].[Tables] T ON [I].[TableID_FK] = [T].[TableID_PK]  WHERE [T].[DatabaseID_FK]= 308</p>
<p>The code that created ths statement is:<br />
  SET @MYSQL = &#8216;DELETE FROM &#8216; + @TABLENAME + @MYJOINCONDITION + &#8216; WHERE &#8216; + @TABLE_FK + &#8216;= &#8216; + CAST(@DBID AS NVARCHAR)</p>
<p>The error SQL is returning is:  Incorrect syntax near &#8216;I&#8217;.</p>
<p>Maybe it&#8217;s just late and my eyes are tired, but I&#8217;m having trouble seing where the error is. Of course, you can tell that I&#8217;m using a join inside the delete statement. </p>
<p>I&#8217;m looking to delete all records from the index table that reference a table that is inside a database that is also being deleted.</p>
<p>As this script continues to attempt to delete the database this error is returned: Msg 547, Level 16, State 0, Line 212<br />
The DELETE statement conflicted with the REFERENCE constraint &#8220;FK_Databases_SQLServer&#8221;. The conflict occurred in database &#8220;MyTestDatabase&#8221;, table &#8220;dbo.Databases&#8221;, column &#8216;DBServerID_FK&#8217;.</p>
<p>Thanks for any time spent in reviewing this design.</p>
<p>Dale</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sohbet</title>
		<link>http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-35769</link>
		<dc:creator><![CDATA[Sohbet]]></dc:creator>
		<pubDate>Sun, 27 Apr 2008 20:54:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-35769</guid>
		<description><![CDATA[thanked post]]></description>
		<content:encoded><![CDATA[<p>thanked post</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sarah</title>
		<link>http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-33073</link>
		<dc:creator><![CDATA[Sarah]]></dc:creator>
		<pubDate>Thu, 17 Jan 2008 23:28:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-33073</guid>
		<description><![CDATA[It&#039;s a really good tip about update. I am wondering if we need to join the same table several times. will the aliases work on the update query? If you have the answer, could you please email it to me. I am getting stuck. Thanks.]]></description>
		<content:encoded><![CDATA[<p>It&#8217;s a really good tip about update. I am wondering if we need to join the same table several times. will the aliases work on the update query? If you have the answer, could you please email it to me. I am getting stuck. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Nadel</title>
		<link>http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-11295</link>
		<dc:creator><![CDATA[Ben Nadel]]></dc:creator>
		<pubDate>Wed, 05 Sep 2007 15:27:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/09/05/sqlauthority-news-interesting-read-using-a-sql-join-in-a-sql-updatedelete-statement-ben-nadel/#comment-11295</guid>
		<description><![CDATA[Pinal Dave, thank you very much for the kind words and the most excellent SQL advice :)]]></description>
		<content:encoded><![CDATA[<p>Pinal Dave, thank you very much for the kind words and the most excellent SQL advice :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
