By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,182 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,182 IT Pros & Developers. It's quick & easy.

Stored Procedure querying another database

P: n/a
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

Feb 6 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Feb 6, 1:25 pm, "mkarb...@gmail.com" <mkarb...@gmail.comwrote:
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

Feb 6 '07 #2

P: n/a
On Feb 6, 5:09 pm, "Steve" <morrisz...@hotmail.comwrote:
On Feb 6, 1:25 pm, "mkarb...@gmail.com" <mkarb...@gmail.comwrote:
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?

Feb 6 '07 #3

P: n/a
mk******@gmail.com (mk******@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, es****@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
Feb 6 '07 #4

P: n/a
On Feb 6, 6:07 pm, Erland Sommarskog <esq...@sommarskog.sewrote:
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?

Feb 6 '07 #5

P: n/a
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

<mk******@gmail.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
On Feb 6, 5:09 pm, "Steve" <morrisz...@hotmail.comwrote:
>On Feb 6, 1:25 pm, "mkarb...@gmail.com" <mkarb...@gmail.comwrote:
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?

Feb 6 '07 #6

P: n/a
On Feb 6, 6:18 pm, "AlterEgo" <altereg...@dslextreme.comwrote:
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.comwrote in message

news:11*********************@m58g2000cwm.googlegro ups.com...
On Feb 6, 5:09 pm, "Steve" <morrisz...@hotmail.comwrote:
On Feb 6, 1:25 pm, "mkarb...@gmail.com" <mkarb...@gmail.comwrote:
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)

Feb 7 '07 #7

P: n/a
marek,

You can't use inherited names. In other words, don't put two periods
together. See my other post.

-- Bill

<mk******@gmail.comwrote in message
news:11********************@v45g2000cwv.googlegrou ps.com...
On Feb 6, 6:07 pm, Erland Sommarskog <esq...@sommarskog.sewrote:
>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?

Feb 7 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.