Qualify Object names - cross database reference
tkdennis
Posts: 114
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.
so I add the USE statement
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
SELECT a_col1, b_col2 FROM db1.dbo.table1 d1 JOIN db2.dbo.table2 d2 ON d1.a_col1 = d2.b_col2becomes
SELECT a_col1, d2.b_col2 FROM db1.dbo.table1 d1 JOIN db2.dbo.table2 d2 ON d1.a_col1 = d2.b_col2but underlines db1.dbo.table1 as not identifiable
so I add the USE statement
USE db1 SELECT a_col1, d2.b_col2 FROM db1.dbo.table1 d1 JOIN db2.dbo.table2 d2 ON d1.a_col1 = d2.b_col2and I now I get this
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_col2and 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
Comments
I am trying to replicate the issue and I will get back to you on this soon!
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
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.
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com