Qualify Object names - cross database reference

Refactors and formats SQL code.

Moderators: Chris Auckland, David Atkinson, Anu Deshpande, Luke Jefferson

Qualify Object names - cross database reference

Postby tkdennis » Mon Jun 07, 2010 7:26 pm

When I have a query that references tables from two databases database, SQL Refactor is not able to find them. If I put a USE <other_database_name> statement at the top (but don't execute it), then it will qualify the names, and tell me it couldn't find the objects from the first database.

Code: Select all
   SELECT a_col1, b_col2
   FROM db1.dbo.table1 d1
   JOIN db2.dbo.table2 d2
      ON d1.a_col1 = d2.b_col2

becomes
Code: Select all
   SELECT a_col1, d2.b_col2
   FROM db1.dbo.table1 d1
   JOIN db2.dbo.table2 d2
      ON d1.a_col1 = d2.b_col2

but underlines db1.dbo.table1 as not identifiable

so I add the USE statement
Code: Select all
USE db1
   SELECT a_col1, d2.b_col2
   FROM db1.dbo.table1 d1
   JOIN db2.dbo.table2 d2
      ON d1.a_col1 = d2.b_col2

and I now I get this
Code: Select all
USE db1
   SELECT d1.a_col1, d2.b_col2
   FROM db1.dbo.table1 d1
   JOIN db2.dbo.table2 d2
      ON d1.a_col1 = d2.b_col2

and it underlines db2.dbo.table2 as not identifiable.

I was in db2 with a USE db2 statement at the top of the script when I first tried it. I got the same result trying to qualify the script in a new window in a 3rd unrelated database without any USE statements - db2 was qualified and db1 was not identified.

Thanks,
Traci
SQL Refactor 1.5.1.61
tkdennis
 
Posts: 75
Joined: Fri Feb 29, 2008 1:13 am

Postby Anu Deshpande » Wed Jun 09, 2010 4:55 pm

Thanks for your post.

I am trying to replicate the issue and I will get back to you on this soon!
Anuradha Deshpande
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
Anu Deshpande
 
Posts: 692
Joined: Mon Apr 20, 2009 3:53 pm
Location: Cambridge

Postby Anu Deshpande » Wed Jun 23, 2010 2:45 pm

Many thanks for your post and apologies for delay in replying you.

I have added your request in our internal tracking system as a feature request whose tracking id is SR-892.

I will update you as soon as this feature is incorporated.

Thanks for your feedback and your patience.
Anuradha Deshpande
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
Anu Deshpande
 
Posts: 692
Joined: Mon Apr 20, 2009 3:53 pm
Location: Cambridge


Return to SQL Refactor 1

Who is online

Users browsing this forum: No registered users and 0 guests