Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Four-part name for Linked Server DB2 Expand / Collapse
Author
Message
Posted Wednesday, February 16, 2005 3:31 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, February 25, 2005 12:52 PM
Points: 12, Visits: 1

I am inserting records from SQL to DB2 through linked server using four-part name. I am connecting with DSN of iSeries AS 400 for DB2. But I am getting strange errors. I have full rights on the table as per my system admin. Basically, I cannot figure out the names of catalog and schema.

The statement I want is

SELECT * FROM <linkedserver name>.<catalog name>.<schema name>.<table name>

1. When I specify Linked server name and table name and skip the catalog and schema names using dots, giving: SELECT * FROM MyLinkedServer1...MyTable

it says:

OLE DB provider 'MyLinkedServer1' does not contain table 'MyTable'.  The table either does not exist or the current user does not have permissions on that table.

2. When I repeat the same thing as above and give table name in uppercase, it says:

Invalid schema or catalog specified for provider 'MSDASQL'.

3. When I try to specify ADMINISTRATOR in schema along with linked server and table name values, it says:

OLE DB provider 'MSDASQL' reported an error. 
[OLE/DB provider returned message: Unspecified error]
[OLE/DB provider returned message: [IBM][iSeries Access ODBC Driver]Invalid string or buffer length.]

4. When I do the same as in point 3 above, with any other schema name (valid or invalid) it says:

OLE DB provider '<linked server name>' does not contain table '"MySchemaName"."MyTable"'.  The table either does not exist or the current user does not have permissions on that table.


Any idea what's happening. Thanks.

Post #162187
Posted Thursday, February 17, 2005 6:46 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, November 12, 2010 8:45 AM
Points: 107, Visits: 62

Do you have iSeries client installed on the SQL Server box?

Have you created the linked server on the SQL Server box?

the four part name should be:

<linked server name>.<catalog/database name>.<library/schema  name>.<table name>




Post #162360
Posted Thursday, February 17, 2005 6:54 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 29, 2013 11:08 AM
Points: 80, Visits: 579

Try something like this,

SELECT *
FROM AS400LinkedServerName.AS400DatabaseName.AS400Library.AS400FileName

You can use the WRKRDBDIRE command to get the AS/400 database name.

 




Post #162362
Posted Wednesday, December 14, 2005 1:03 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 26, 2012 2:39 PM
Points: 1, Visits: 17

A couple of notes here. .

Using Enterprise manager On the Linked server listing of the tables connected through the “client Access” System DNS ODBC it tells you the "schema" and "catalog" names to use (on the right side of the screen once you select the tables under your linked server name) !!

and for me these needed to be all in caps ..and it was case sensitive!!

Post #244254
Posted Friday, May 11, 2007 5:37 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 08, 2007 9:08 AM
Points: 1, Visits: 1

I use select statement to select one order. It take 9 seconds.

But OPENQUERY only take 0.1 seconds to select one order.

Do anyone know why?

How can we make select statement run faster?

Our application only support select statement.

Thanks,

David

 

Post #365359
Posted Monday, May 14, 2007 1:24 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, May 15, 2013 8:57 AM
Points: 963, Visits: 346

tony,

Try comparing the execution plans for both methods from inside Query Analyzer. 

Post #365755
Posted Tuesday, November 27, 2007 7:31 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 27, 2007 10:54 AM
Points: 3, Visits: 5
From a microsoft article http://msdn2.microsoft.com/en-us/library/aa936673(sql.80).aspx

Avoiding Four-Part Naming
It is possible to access the data of a cube directly from SQL Server using queries with four-part naming. (The four parts are linked-server-name, catalog, schema, and table.) However, this option is not recommended because SQL Server attempts to copy the contents of the entire fact table and then perform the calculations for aggregating the data itself, substantially increasing the query response time.

I know that this doesn't precisely apply to your situation, but I had a similar problem when comparing performance on openquery() vs. four-part naming and this is as close as I could find to an explanation. Hope it helps.
Post #426370
Posted Tuesday, November 27, 2007 8:01 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 29, 2013 11:08 AM
Points: 80, Visits: 579
Openquery passes the query to the linked server and it runs on the linked server. With 4 part naming the query runs on the machine the query was started on and pulls data over.

It will really make a difference if you have a lot it joins.



Post #426402
Posted Tuesday, November 27, 2007 8:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 27, 2007 10:54 AM
Points: 3, Visits: 5
I recognize the advantage of using OpenQuery, but my delima is that I need to use parameter values passed into a SP w/in the OpenQuery function. i.e.:

SELECT * FROM OPENQUERY(COINS_IMAGING, '
SELECT po.ohd_dbid, po.ohd_po, cust.rcm_name
FROM pub.po_header po
INNER JOIN pub.sm_wkord wkord ON po.ohd_wonum = wkord.swo_wo_no
INNER JOIN pub.ar_cust cust ON wkord.swo_cust = cust.rcm_num
WHERE po.ohd_dbid = ''' + @Company + '''
and po.ohd_po = ''' + @PO_num + '''
');


I get an error w/ this syntax, though:
Msg 102, Level 15, State 1, Procedure uspPO_VendorName_WO, Line 13
Incorrect syntax near '+'.

I'm not sure it's possible.
Post #426408
Posted Tuesday, November 27, 2007 8:13 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 29, 2013 11:08 AM
Points: 80, Visits: 579
I don't think you can.

From 2000 BOL, "OPENQUERY does not accept variables for its arguments."



Post #426410
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse