Tuesday, January 28, 2014

SQL Reference two database instances in a query


Within a SQL query or stored procedure, multiple database tables can be referenced.  The full database name just needs to be specified in the query.

 

SELECT *

FROM Appointment a

INNER JOIN TableLog.dbo.Appointment al ON al.appointmentid=a.appointmentid

WHERE a.appointmentid = @appointmentid

No comments: