Link to home
Start Free TrialLog in
Avatar of williak7
williak7Flag for United States of America

asked on

Can't get 4 part naming to work on as400 link

I have a two part question:

1)  I have an as400 linked through my sqlexpress 2005.  I am successfull in quering the database using this statement:

Select * From OpenQuery(MHAS400,'Select * From QGPL.DLY_PROD')

However, I would like to use the four part naming.  I am using this statement, but not sure what to use for the QSECOFR.

select * from MHAS400.QGPL.QSECOFR.DLY_PROD

MHAS400 -linked server
QGPL - library
QSECOFR - user with acces to library (this is where I am not sure I have the correct info)
DLY_PROD- file/table

So what is the 3rd section of the 4 part naming convention?  

2) And will I be able to accomplish my goal pulling data from both the AS400 and SQL in the same statement similiar to this...

select * from MHAS400.QGPL.??.DLY_PROD as A
inner join SQLServer.SQLDBe.DBO.SQLTable as B on B.USADATE = A.USADATE

and retrieve data from both server much like querying two sql servers?

Thanks for the help on this.
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

you can write 2) as ...

select *
from (Select * From OpenQuery(MHAS400,'Select * From QGPL.DLY_PROD')) as A
inner join SQLServer.SQLDBe.DBO.SQLTable as B
on B.USADATE = A.USADATE

for 1) since you don't specify qsecfor in the openquery... i'm not sure what you're trying to achieve...

Avatar of williak7

ASKER

I tried qsecofr, but that didn't work.  The ?? were to represent the fact that I didn't know what went there.  I also tried a number of user id's that have access to the db.  I have seen where the 3rd part was respresented as dbo or schema, but I am not familiar enough with as400/db2 to know what that would be.

i did get your response to work.  I will see if my first part gets answered and post the points.

kevin
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial