0

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.

Dan Getz
  • 8,774
  • 6
  • 30
  • 64
Ralph G
  • 133
  • 1
  • 6

1 Answers1

1

Create a linked server on your ms sql server to the Sybase db. Write a stored procedure in sql server that:

  1. Creates a temporary table
  2. Uses openquery to populate the temp table from the Sybase db
  3. Runs a select query that left joins the sql server table to the temporary table.
Dan Bracuk
  • 20,699
  • 4
  • 26
  • 43
  • How to openquery from ms sql to sybase ? Thank you – Ralph G Sep 09 '14 at 02:41
  • 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