Reputation: 121
I am doing task of retrieving the data from both database tables,I included following query to achieve it.
Query in stored procedure:
--Some query here...
LEFT OUTER JOIN aaa c
ON l.IDNo = c.LogonIDNo
INNER JOIN Data_00.dbo.yyy A
ON C.MacCusNo = A.Cus_no
LEFT OUTER JOIN abc T
ON A.xyz = T.bbb
Tables:
aaa : table of database Data_01
yyy : table of database Data_00
Is there any way to retrieve the data from both the database tables without using 'Data_00.dbo.yyy' I want to use only yyy
instead of it.
Upvotes: 3
Views: 447
Reputation: 1186
I'll assume you're using SQL Server.
Yes, you can create a synonym. Synonyms allow you to specify a shorthand name for accessing various database objects, whether they reside in the same database as the synonym rule or not.
USE Data_01;
CREATE SYNONYM yyy FOR Data_00.dbo.yyy;
Upvotes: 9