Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-06-16
3
Medium Priority
?
287 Views
Last Modified: 2008-03-17
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.
0
Comment
Question by:williak7
  • 2
3 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 16924761
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...

0
 

Author Comment

by:williak7
ID: 16925075
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
0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 2000 total points
ID: 16925139
i think qgpl (your library) is actually the owner or schema ....

(a user doesn't normally own ... a table or view in db2... although he can have an alias or synonm defined for a table/view)

you may be able to get

mhas400.mhas400.qgpl.dlt_prod

to work ...

but the second mhas400 need to be the name of the subsystem or instance of DB2/UDB on the AS400...

you need to ask the as400 dba how his system is named internally and what aliases/nicknames he's exposed wants you to use...


btw do you know the version of DB2/UDB you're trying to connect to...  


hth
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question