Can anyone give me an idea on how to select from a table in another database? For example, in my MS SQL database I have a table named employee
, and I want to create a query to left join on a Sybase database table employee
.
Asked
Active
Viewed 308 times
0
-
You can BCP out the table out from one server and BCP in into other server. – Meet Sep 09 '14 at 10:26
1 Answers
1
Create a linked server on your ms sql server to the Sybase db. Write a stored procedure in sql server that:
- Creates a temporary table
- Uses openquery to populate the temp table from the Sybase db
- Runs a select query that left joins the sql server table to the temporary table.

Dan Bracuk
- 20,699
- 4
- 26
- 43
-
-
Once you have your linked server set up, it's select * from openquery (linkedServerName, 'select query goes here'). Note that the server name is not quoted but the sql is. – Dan Bracuk Sep 09 '14 at 12:30