[CodeBlog] Legacy database? Want to make it appear as part of an MS SQL database? - by simon at Wed, 03 Nov 2004 21:35:04 GMT
You can do this using the OPENROWSET function in MS SQL Server, so:
SELECT * FROM OPENROWSET('MSDASQL', 'ConnectionString', 'SELECT * FROM mytable')
Which is great in a view for data consolidation - but even better is to remove the need for a connection string by connecting just once!
You can do this using sp_addlinkedserver and sp_addlinkedsrvlogin. Requirements will change depending on what you want to connect to - if you need help with a particular one feel free to e-mail me.
You can then simply use the new 'server' you just set up as so:
SELECT * FROM OPENQUERY(servername, 'SELECT * FROM mytable')
Permalink
Copyright © 2001-2024 Simon Soanes