question

oau avatar image
oau asked

linked server

I have created a linked server to AS400. In AS400 we have table names like AT.ITEM when I write a SQL on query analyzer using openquery for e.q `SELECT * FROM OPENQUERY(AS400, 'SELECT name, id FROM AS400LIB."AT.ITEM"')` It worsk but if I write SQL like SELECT * FROM AS400... "AT.ITEM" its give an error..
t-sqllinked-server
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Magnus Ahlkvist avatar image Magnus Ahlkvist commented ·
What error do you receive?
1 Like 1 ·
sp_lock avatar image sp_lock commented ·
Like @Magnus says, it is hard to offer advice without any errors. Edit your post with the details
0 Likes 0 ·
Håkan Winther avatar image
Håkan Winther answered
I recommend you to use OPENQUERY syntax for the best performance at least if the table is large. I also recommend you to specify the columns you need (don't use the SELECT * syntax) and specify a WHERE clause that use an index if you can. You also need to specify SET QUOTED IDENTIFIER ON to be able to use the double quotes. The syntaxt to use a linked table name in T-SQL is LINKEDSERVERNAME.DATABASENAME.SCHEMA.OBJECTNAME Is the name of your object "AT.ITEM"? or is AT your schema name?
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

oau avatar image
oau answered
Thanks AT.ITEM is an object name because of dot in object name i'm geeting error in simple SQL.. however if I'm using Openquery with above syntax its working fine I'm getting this error if i right sim[ple SQL Server: Msg 7306, Level 16, State 2, Line 1 Could not open table 'AT.ITEM' from OLE DB provider 'MSDASQL'. The specified table does not exist. [OLE/DB provider returned message: [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0204 - ITEM in AT type *FILE not found.] OLE DB error trace [OLE/DB Provider 'MSDASQL' IOpenRowset::OpenRowset returned 0x80040e37: The specified table does not exist.].
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image
ThomasRushton answered
If you run SELECT * FROM AS400...[AT.ITEM] does that work?
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

oau avatar image
oau answered
i tried it its not working too
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·
Same error message?
0 Likes 0 ·
oau avatar image
oau answered
yes same error message
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Håkan Winther avatar image
Håkan Winther answered
Have you tried all combinations like: SELECT * FROM AS400..AT.ITEM or SELECT * FROM AS400.."AT.ITEM"
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

oau avatar image
oau answered
yes did i tries with [AT.ITEM] and "AT.ITEM" both are not working.."AT.ITEM" is woorking for openquery
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

oau avatar image
oau answered
its working like this AS400...["AT.ITEM"]
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.