Skip to main content
Question

Hi there I am trying to use SQL Executor but getting an error

  • October 20, 2020
  • 3 replies
  • 140 views

gisgeek
Contributor
Forum|alt.badge.img+9

This is the statement I am using in SQL Executor. It runs fine in SQL Server Management studio.

 

update a set ParcelID = NewParcelID, KOAUnitID 

from  

(select a.ParcelID,b.ParcelID NewParcelID,a.KOA_UNIT_ID KOAUnitID from   

[GISStaging].[dbo].[KAINGAORALETTABLEUNITSTAGINGNZTM] a left join  

GISPublish.dbo.Parcel b on a.shape.STIntersects(b.shape) = 1) a 

 

and this is the error message:

Microsoft SQL Server Spatial Reader: Query failed, possibly due to a malformed statement. Query Text `update a set ParcelID = NewParcelID, KOAUnitID

from

(select a.ParcelID,b.ParcelID NewParcelID,a.KOA_UNIT_ID KOAUnitID from

[GISStaging].[dbo].[KAINGAORALETTABLEUNITSTAGINGNZTM] a left join

GISPublish.dbo.Parcel b on a.shape.STIntersects(b.shape) = 1) a'. Provider error `(-2147217900) Incorrect syntax near the keyword 'from'.'

A fatal error has occurred. Check the logfile above for details

3 replies

redgeographics
Celebrity
Forum|alt.badge.img+47

I'm not a big SQL guru so I may be completely wrong here, but it looks like you're using an alias "a" without actually defining what "a" is.


jkr_wrk
Influencer
Forum|alt.badge.img+28
  • October 20, 2020

It is a pretty complex query you are writing. Are you sure it's working?

 

My Sql skills ain't perfect but do you select a table name 'a' with the select statement?

Using 'a' twice is a bit confusing to me. Are you sure the select statement gives back one result and one result only?

 

You 'Set ParcelID = NewParcelID' but don't set KOAUnitID to anything. Why do you mention it. Don't you need a WHERE statement?

 

update a set ParcelID = NewParcelID, KOAUnitID from 
	(select a.ParcelID,b.ParcelID NewParcelID,a.KOA_UNIT_ID KOAUnitID from [GISStaging].[dbo].[KAINGAORALETTABLEUNITSTAGINGNZTM] a left join GISPublish.dbo.Parcel b on a.shape.STIntersects(b.shape) = 1) a 

 


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • October 20, 2020

Try removing all the line breaks/carriage returns from the UPDATE statement in FME and making it one long single SQL statement line.

I seem to remember getting a similar issue in a SQL statement executing fine in SQL Server Management Studio but not in SQLCreator was because these end-of-line/carriage return characters can get malformed when copying and pasting the SQL statement text from SQL Server Management Studio to FME an then FME not parsing the SQL statement string properly when it sends the statement to the SQL Server Provider. I didn't investigate much further as to why this happened, but it solved my particular problem.

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings