|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, January 29, 2013 1:49 PM
Points: 5,
Visits: 47
|
|
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:
@sqlcmd='SELECT c.CustomerID, c.CustomerName, o.OrderID, o.OrderDate FROm Customer c JOIN Orders o ON o.CustomerID=c.CustomerID'
I'm looking for a way to get the following output
Customer Order
Any ideas? I was hoping there might be a system proc that might help...
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 3:22 PM
Points: 11,792,
Visits: 28,077
|
|
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:
select OBJECT_NAME(referencing_id) As ViewName, OBJECT_NAME(referenced_id) As ReferencedObject from sys.sql_expression_dependencies WHERE OBJECT_NAME(referencing_id) = 'VW_MyTempVIEW'
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 3:22 PM
Points: 11,792,
Visits: 28,077
|
|
also, look at this rather long thread: Select table names from queries
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:
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, January 29, 2013 1:49 PM
Points: 5,
Visits: 47
|
|
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.
|
|
|
|