This is a discussion on Stored Procedure querying another database within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello, I need to come up with a stored procedure that will allow me to read data from another ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello, I need to come up with a stored procedure that will allow me to read data from another database. The database I need to read the data from is a UniData residing on a Unix server. The stored procedure needs to reside on my sql 2005 server. The task is very simple in Access as we have ODBC connections set up to the UniData via Informix (or IBM) UniData ODBC drivers. I can easily combine my UniData and Sql Server tables from within access. However, I can't seem to find a way to replicate the same behavior in MS SQL Stored Procedure without the use of Access. Is that even possible? Thanks, Marek |
| |||
| On Feb 6, 1:25 pm, "mkarb...@gmail.com" <mkarb...@gmail.com> wrote: > Hello, > > I need to come up with a stored procedure that will allow me to read > data from another database. The database I need to read the data from > is a UniData residing on a Unix server. The stored procedure needs to > reside on my sql 2005 server. The task is very simple in Access as we > have ODBC connections set up to the UniData via Informix (or IBM) > UniData ODBC drivers. I can easily combine my UniData and Sql Server > tables from within access. However, I can't seem to find a way to > replicate the same behavior in MS SQL Stored Procedure without the use > of Access. Is that even possible? > > Thanks, > > Marek Linked server or OPENROWSET In SQL Server 2005 Books Online see the topic: Distributed Queries |
| |||
| On Feb 6, 5:09 pm, "Steve" <morrisz...@hotmail.com> wrote: > On Feb 6, 1:25 pm, "mkarb...@gmail.com" <mkarb...@gmail.com> wrote: > > > Hello, > > > I need to come up with a stored procedure that will allow me to read > > data from another database. The database I need to read the data from > > is a UniData residing on a Unix server. The stored procedure needs to > > reside on my sql 2005 server. The task is very simple in Access as we > > have ODBC connections set up to the UniData via Informix (or IBM) > > UniData ODBC drivers. I can easily combine my UniData and Sql Server > > tables from within access. However, I can't seem to find a way to > > replicate the same behavior in MS SQL Stored Procedure without the use > > of Access. Is that even possible? > > > Thanks, > > > Marek > > Linked server or OPENROWSET > In SQL Server 2005 Books Online see the topic: Distributed Queries I started playing around with the linked server and I got it to the point where I can see the tables from UniData, but when I try to query it using LINKEDSERVERNAME...TABLE I get 'Invalid schema or catalog specified for provider 'MSDASQL'." error. When I try to specify schema using LINKEDSERVERNAME.SCHEMA.TABLE I get 'Invalid object name LINKEDSERVERNAME.SCHEMA.TABLE'; do you know why these errors occur and how to get around them? |
| |||
| mkarbarz@gmail.com (mkarbarz@gmail.com) writes: > I started playing around with the linked server and I got it to the > point where I can see the tables from UniData, but when I try to query > it using LINKEDSERVERNAME...TABLE I get 'Invalid schema or catalog > specified for provider 'MSDASQL'." error. When I try to specify > schema using LINKEDSERVERNAME.SCHEMA.TABLE I get 'Invalid object name > LINKEDSERVERNAME.SCHEMA.TABLE'; do you know why these errors occur > and how to get around them? To refer to an object on a remote server, you must use four-part notation: server.catalog.schema.table. So that's why INKEDSERVERNAME.SCHEMA.TABLE does not work. Unfortunately, I have no idea what will work, since I've never heard of Unidata before. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |
| |||
| On Feb 6, 6:07 pm, Erland Sommarskog <esq...@sommarskog.se> wrote: > mkarb...@gmail.com (mkarb...@gmail.com) writes: > > I started playing around with the linked server and I got it to the > > point where I can see the tables from UniData, but when I try to query > > it using LINKEDSERVERNAME...TABLE I get 'Invalid schema or catalog > > specified for provider 'MSDASQL'." error. When I try to specify > > schema using LINKEDSERVERNAME.SCHEMA.TABLE I get 'Invalid object name > > LINKEDSERVERNAME.SCHEMA.TABLE'; do you know why these errors occur > > and how to get around them? > > To refer to an object on a remote server, you must use four-part > notation: server.catalog.schema.table. So that's why > INKEDSERVERNAME.SCHEMA.TABLE does not work. > > Unfortunately, I have no idea what will work, since I've never heard of > Unidata before. > > -- > Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se > > Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books... > Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx I started using the 4 part query and I guess I got a step further; now I'm getting a different error: the query is: SELECT * FROM AVLIVE..ii.SODET_NF the error: [OLE/DB provider returned message: Unspecified error] [OLE/DB provider returned message: [Ardent][UniData ODBC Driver]Invalid column number.] OLE DB error trace [OLE/DB Provider 'MSDASQL' IDBSchemaRowset::GetRowset returned 0x80004005: ]. Msg 7399, Level 16, State 1, Line 1 OLE DB provider 'MSDASQL' reported an error. Any idea what this error means? |
| |||
| Marek, In order to use a linked server, the server has to be capable of a four part namespace. Your example was only showing a three part namespace. You were using: LINKEDSERVERNAME.SCHEMA.TABLE You need to be able to specify: LINKEDSERVERNAME.DATABASE.SCHEMA.TABLE Do the ODBC drivers and databases you are using support a four-part name. If they don't, then you will have to use OPENROWSET. I don't know about SQL 2005, but in SQL 2K you can not inherit any part of the namespace if the database is on a different server. The following won't work: LINKEDSERVERNAME.DATABASE..TABLE -- Bill <mkarbarz@gmail.com> wrote in message news:1170801310.273492.21720@m58g2000cwm.googlegro ups.com... > On Feb 6, 5:09 pm, "Steve" <morrisz...@hotmail.com> wrote: >> On Feb 6, 1:25 pm, "mkarb...@gmail.com" <mkarb...@gmail.com> wrote: >> >> > Hello, >> >> > I need to come up with a stored procedure that will allow me to read >> > data from another database. The database I need to read the data from >> > is a UniData residing on a Unix server. The stored procedure needs to >> > reside on my sql 2005 server. The task is very simple in Access as we >> > have ODBC connections set up to the UniData via Informix (or IBM) >> > UniData ODBC drivers. I can easily combine my UniData and Sql Server >> > tables from within access. However, I can't seem to find a way to >> > replicate the same behavior in MS SQL Stored Procedure without the use >> > of Access. Is that even possible? >> >> > Thanks, >> >> > Marek >> >> Linked server or OPENROWSET >> In SQL Server 2005 Books Online see the topic: Distributed Queries > > I started playing around with the linked server and I got it to the > point where I can see the tables from UniData, but when I try to query > it using LINKEDSERVERNAME...TABLE I get 'Invalid schema or catalog > specified for provider 'MSDASQL'." error. When I try to specify > schema using LINKEDSERVERNAME.SCHEMA.TABLE I get 'Invalid object name > LINKEDSERVERNAME.SCHEMA.TABLE'; do you know why these errors occur > and how to get around them? > |
| |||
| On Feb 6, 6:18 pm, "AlterEgo" <altereg...@dslextreme.com> wrote: > Marek, > > In order to use a linked server, the server has to be capable of a four part > namespace. Your example was only showing a three part namespace. > > You were using: > LINKEDSERVERNAME.SCHEMA.TABLE > > You need to be able to specify: > LINKEDSERVERNAME.DATABASE.SCHEMA.TABLE > > Do the ODBC drivers and databases you are using support a four-part name. If > they don't, then you will have to use OPENROWSET. > > I don't know about SQL 2005, but in SQL 2K you can not inherit any part of > the namespace if the database is on a different server. The following won't > work: > > LINKEDSERVERNAME.DATABASE..TABLE > > -- Bill > > <mkarb...@gmail.com> wrote in message > > news:1170801310.273492.21720@m58g2000cwm.googlegro ups.com... > > > > > On Feb 6, 5:09 pm, "Steve" <morrisz...@hotmail.com> wrote: > >> On Feb 6, 1:25 pm, "mkarb...@gmail.com" <mkarb...@gmail.com> wrote: > > >> > Hello, > > >> > I need to come up with a stored procedure that will allow me to read > >> > data from another database. The database I need to read the data from > >> > is a UniData residing on a Unix server. The stored procedure needs to > >> > reside on my sql 2005 server. The task is very simple in Access as we > >> > have ODBC connections set up to the UniData via Informix (or IBM) > >> > UniData ODBC drivers. I can easily combine my UniData and Sql Server > >> > tables from within access. However, I can't seem to find a way to > >> > replicate the same behavior in MS SQL Stored Procedure without the use > >> > of Access. Is that even possible? > > >> > Thanks, > > >> > Marek > > >> Linked server or OPENROWSET > >> In SQL Server 2005 Books Online see the topic: Distributed Queries > > > I started playing around with the linked server and I got it to the > > point where I can see the tables from UniData, but when I try to query > > it using LINKEDSERVERNAME...TABLE I get 'Invalid schema or catalog > > specified for provider 'MSDASQL'." error. When I try to specify > > schema using LINKEDSERVERNAME.SCHEMA.TABLE I get 'Invalid object name > > LINKEDSERVERNAME.SCHEMA.TABLE'; do you know why these errors occur > > and how to get around them?- Hide quoted text - > > - Show quoted text - thanks for all your help; indeed with OPENROWSET I was able to get the query working with no problems (or at least the problems I'm having are not related to the tables, rather with Error converting data type DBTYPE_DBDATE to datetime, but that's a topic for another thread if I can't figure it out) |
| ||||
| marek, You can't use inherited names. In other words, don't put two periods together. See my other post. -- Bill <mkarbarz@gmail.com> wrote in message news:1170804277.261564.3540@v45g2000cwv.googlegrou ps.com... > On Feb 6, 6:07 pm, Erland Sommarskog <esq...@sommarskog.se> wrote: >> mkarb...@gmail.com (mkarb...@gmail.com) writes: >> > I started playing around with the linked server and I got it to the >> > point where I can see the tables from UniData, but when I try to query >> > it using LINKEDSERVERNAME...TABLE I get 'Invalid schema or catalog >> > specified for provider 'MSDASQL'." error. When I try to specify >> > schema using LINKEDSERVERNAME.SCHEMA.TABLE I get 'Invalid object name >> > LINKEDSERVERNAME.SCHEMA.TABLE'; do you know why these errors occur >> > and how to get around them? >> >> To refer to an object on a remote server, you must use four-part >> notation: server.catalog.schema.table. So that's why >> INKEDSERVERNAME.SCHEMA.TABLE does not work. >> >> Unfortunately, I have no idea what will work, since I've never heard of >> Unidata before. >> >> -- >> Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se >> >> Books Online for SQL Server 2005 >> athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books... >> Books Online for SQL Server 2000 >> athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx > > I started using the 4 part query and I guess I got a step further; > now I'm getting a different error: > > the query is: SELECT * FROM AVLIVE..ii.SODET_NF > > the error: > [OLE/DB provider returned message: Unspecified error] > [OLE/DB provider returned message: [Ardent][UniData ODBC > Driver]Invalid column number.] > OLE DB error trace [OLE/DB Provider 'MSDASQL' > IDBSchemaRowset::GetRowset returned 0x80004005: ]. > Msg 7399, Level 16, State 1, Line 1 > OLE DB provider 'MSDASQL' reported an error. > > Any idea what this error means? > |