﻿<?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 2008 - General  / How to get list of affected tables in an Query / 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>Sat, 18 May 2013 10:39:09 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How to get list of affected tables in an Query</title><link>http://www.sqlservercentral.com/Forums/Topic1407744-391-1.aspx</link><description>Hi Lowell,Thanks for taking the time to have a look.  I will run some tests for both of these.  I prefer creating a temp View and checking the dependancies and then dropping as I suspect that some of the system procs for obtaining execution paths are probably not available in Azure.  I will update this thread with my test results and then eventually my work.So far I have a script to create a temp table for a INSERT INTO SELECT... to replace the SELECT * INTO FROM (unsupported in Azure) which will allow any number of fields to be used without defining the destination temp table up front (which is my issue).  This currently works on the results of one table (no joins) - your proposed solution may help me get to a temp table query with joins... I will post results.</description><pubDate>Thu, 17 Jan 2013 00:31:16 GMT</pubDate><dc:creator>Paul McKenzie</dc:creator></item><item><title>RE: How to get list of affected tables in an Query</title><link>http://www.sqlservercentral.com/Forums/Topic1407744-391-1.aspx</link><description>also, look at this rather long thread:[b][url=http://www.sqlservercentral.com/Forums/Topic1351799-392-1.aspx]Select table names from queries[/url][/b]in that thread you'll find a lot of ideas, but the one i'm referring to is Eugene Elutin's posts  on page 4 of the thread, where he is reading the execution plan cache and parsing the xml for the table values:</description><pubDate>Wed, 16 Jan 2013 13:26:30 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: How to get list of affected tables in an Query</title><link>http://www.sqlservercentral.com/Forums/Topic1407744-391-1.aspx</link><description>is this a one time kind of thing?you could create a VIEW that uses the query, then check sys.sql_expression_dependencies for the objects, and then drop the view again:[code]select OBJECT_NAME(referencing_id) As ViewName,OBJECT_NAME(referenced_id) As ReferencedObjectfrom sys.sql_expression_dependencies WHERE OBJECT_NAME(referencing_id) = 'VW_MyTempVIEW'[/code]</description><pubDate>Wed, 16 Jan 2013 13:17:02 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>How to get list of affected tables in an Query</title><link>http://www.sqlservercentral.com/Forums/Topic1407744-391-1.aspx</link><description>Hi Guys,First post here. Have a problem trying to build a work around for SQL Azure not supporting SELECT INTO...As part of my solution, I need to get a table result containing a list of affected tables in a query. eg:[code="sql"]@sqlcmd='SELECT 	c.CustomerID,	c.CustomerName,	o.OrderID,	o.OrderDateFROm Customer cJOIN Orders o ON o.CustomerID=c.CustomerID'[/code]I'm looking for a way to get the following output[code="sql"]CustomerOrder[/code]Any ideas? I was hoping there might be a system proc that might help...</description><pubDate>Wed, 16 Jan 2013 04:40:53 GMT</pubDate><dc:creator>Paul McKenzie</dc:creator></item></channel></rss>