Hi,
I'm trying to create a database that takes specific information from a number of databases on different servers to make some reporting that we have much easier.
I'm pretty new to SQL so I'm not sure of the best way to proceed. I read an article that suggested I use the OPENROWSET command. The problem is, the version of SQL that came with one of the programmes we use is limited and will not allow you to turn on the allow "Ad Hoc distributed Queries" so the SLQ statement will not execute.
I'm confused why it won't let me to connect through ODBC as I've created a web page that selects data from this database with no problems!
Here is the SQL statement that I've written to make sure it is the correct one (on the msdn library page it said that this was the ODBC connection):
SELECT a.*
FROM OPENROWSET('MSDASQL','DRIVER=(SQL Server);SERVER=APPOLO\ACT7;UID=sa;PWD=***************',
'SELECT * FROM MDCTestAndDev.dbo.TBL_CONTACT') AS a
I've also created the ODBC connection using the tool on Administration Tools>Data Sources ODBC
Any help would be greatly appreciated (also any ways of selecting from one database and inserting it into another will be helpfull)
Thanks
Which version of SQL Server your using (2000 or 2005)?|||Hi I'm using the Express 2005 Edition|||'ad-hoc dist' property controls whether or not the use of OpenRowset/Datasource is allowed. If it's not enabled, you will not be able to execute the query, regardless of the data access provider you use.
Your only option is to create a linked server and use OpenQuery() or 4-part name query.
http://msdn2.microsoft.com/en-us/library/ms190479.aspx
|||Thanks for the reply
I have managed to create a linked server using the following bit of code:
Code Snippet
EXEC sp_addlinkedserver
@.server = 'APPOLO/ACT7',
@.srvproduct = 'SQLServr OLEDB Provider',
@.provider = 'MSDASQL',
@.datasrc='ACT7'
GO
I then created and ran the following statement:
Code Snippet
SELECT *
FROM OPENQUERY(APPOLO/ACT, 'SELECT * FROM mdc1.TBL_CONTACTS')
I then get the following error message:
"Incorrect Syntac near '/'"
I have tried only using "APPOLO", "ACT7", "APPOLO.ACT7" and putting them all in quotation marks but it does not work.
Any Ideas?
|||How about:
[APPOLO/ACT]
HTH!|||Great - that solved that problem -
I'm now getting a message to say that authentication failed - I guess this is because I havent provided the sa password - how do i enter this so that I can connect?
Thanks
Tom
|||You use this to set the login.
Code Snippet
EXEC sp_addlinkedsrvlogin 'APPOLO/ACT', 'false', NULL, 'sa', 'Password'
No comments:
Post a Comment