2

I'm trying to create a table view using SQL to join a table and a feature class together. When I try to create the view, I get an error saying there is an incorrect syntax near the keyword 'CREATE'. I've double checked my syntax with other examples and I can't figure out where I'm going wrong. I've attached the short script below:

CREATE VIEW OpDash_points AS SELECT
 P.OBJECTID,
 P.SITE,
 P.edited_names,
 P.Field12,
 P.Shape,
 O.Asset,
 O.Project_Name,
 O.Project_Status

 FROM
  tstgis.MPCGIS.Subs_Switches_Telecomm P,
  tstgis.MBRESNAHAN.OpDash_data O

 WHERE
  P.SITE = O.Asset;
  • 1
    maybe a comma after" ..._Telecom P" in the from part ? – J.R Nov 14 '19 at 14:03
  • Good eye, though I just fixed it and it gave me the same error. – Mark1994 Nov 14 '19 at 14:07
  • 1
    Best practice is to use the JOIN keyword instead of multiple tables in the FROM and a WHERE to force the join, but your SQL engine (whatever is might be) might use a different syntax to create views. – Vince Nov 14 '19 at 14:13
0

Try this

CREATE VIEW opDash_points as 
Select P.objectid
    , P.site
    , P.edited_names
    , P.Field12
    , P.Shape
    , O.Asset
    , O.Project_Name
    , O.Project_status
FROM tstgis.MPCGIS.Subs_Switches_Telecom P inner join 
        tstgis.NBRESHNAHA.OpDash_data O
            on P.Site = O.Asset
  • 1
    Thanks! The problem ended up being the syntax for the first line. I didn't need the CREATE VIEW syntax, just the SELECT syntax. The script is working now. – Mark1994 Nov 19 '19 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.