• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 676
  • Last Modified:

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

0
kdeutsch
Asked:
kdeutsch
  • 2
1 Solution
 
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
 
kdeutschAuthor Commented:
angelIII:,

Thanks i see what I was doing wrong.
0
 
kdeutschAuthor Commented:
awesome, thanks agian
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now