Sql query error on OPENQuery

I had to change this statment to work better since it is working over a linked sql to oracle server to grab information from a db.  I changed a portion to OPENQUERY where it hits the linked server but now I get the following errors, I have tried a lot of sytaxes at this point but get new error everytime.
 

Errors
Msg 156, Level 15, State 1, Line 12
Incorrect syntax near the keyword 'Select'.
Msg 156, Level 15, State 1, Line 13
Incorrect syntax near the keyword 'on'.

Select	p.intPositionId, 
		p.strPara, 
		p.strline, 
		'ISSUE MOB ORDER', 
		isnull(pp.dtLateMob, da.dtDeployDate), 
		pp.strName, 
		pp.strSSN 
from	tblUnitPosition as p INNER JOIN 
		tblUnitPersonnel as pp on p.intPositionId = pp.intPositionId INNER JOIN 
		cms.dbo.tblsidpers as s on s.sidstrSSN_SM = pp.strssn INNER JOIN 
		tblUnitDeployData as da On da.intUnitMobID = p.IntUnitMobID LEFT OUTER JOIN 
		Select * from OPENQUERY(SIDPERS, 'Select FTDHIST_SSN, FTDHIST_START, FTDHIST_END, substring(FTDHIST_PAS,3,5) as UIC 
								from COMP.JSSFTDHIST where FTDHIST_TDC = ''MOB'' )') as mob on pp.strssn = mob.FTDHIST_SSN and 
								isnull(pp.dtLateMob, da.dtDeployDate) = mob.FTDHIST_START Where isnull(mob.FTDHIST_SSN,'BAD') = 'BAD' and 
								(isnull(pp.dtLateMob, da.dtDeployDate) < DateADD(day, 90, getdate())) And p.intUnitMobId > 0

Open in new window

kdeutschAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
openquery is like a view, so:
Select	p.intPositionId, 
		p.strPara, 
		p.strline, 
		'ISSUE MOB ORDER', 
		isnull(pp.dtLateMob, da.dtDeployDate), 
		pp.strName, 
		pp.strSSN 
from	tblUnitPosition as p INNER JOIN 
		tblUnitPersonnel as pp on p.intPositionId = pp.intPositionId INNER JOIN 
		cms.dbo.tblsidpers as s on s.sidstrSSN_SM = pp.strssn INNER JOIN 
		tblUnitDeployData as da On da.intUnitMobID = p.IntUnitMobID LEFT OUTER JOIN 
		OPENQUERY(SIDPERS, 'Select FTDHIST_SSN, FTDHIST_START, FTDHIST_END, substring(FTDHIST_PAS,3,5) as UIC 
								from COMP.JSSFTDHIST where FTDHIST_TDC = ''MOB'' 
                                          ' ) as mob 
                    on pp.strssn = mob.FTDHIST_SSN and 
								isnull(pp.dtLateMob, da.dtDeployDate) = mob.FTDHIST_START Where isnull(mob.FTDHIST_SSN,'BAD') = 'BAD' and 
								(isnull(pp.dtLateMob, da.dtDeployDate) < DateADD(day, 90, getdate())) And p.intUnitMobId > 0

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kdeutschAuthor Commented:
angelIII:,

Thanks i see what I was doing wrong.
0
kdeutschAuthor Commented:
awesome, thanks agian
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.