How can I alias a field and set to NULL when creating a Query Layer?

115
2
04-24-2019 03:58 PM
PhilLarkin1
Regular Contributor

I'd like to do this, which is perfectly acceptable in SSMS:

SELECT A, B, NULL AS 'C', Shape FROM database.dbo.PARCELS WHERE PID_NUM IN ( 'someCriteria')

When I pass this query to MakeQueryLayer_Management it will create the object but no records are returned. If i drop " NULL AS 'C' " the Query Layer will be populated with rows. I am 100% confident my query returns records.

What is the proper syntax in ESRI's implementation of SQL to populate an aliased field with NULL? 

0 Kudos
2 Replies
JoshuaBixby
MVP Esteemed Contributor

I just tried:

SELECT [OBJECTID]
      ,[SPID]
      , NULL as 'D'
      ,[SHAPE]
  FROM [SGDB].[dbo].[SIGNPOSTS]

and got:

I just used the GUI really quick, haven't tried using the geoprocessing tool yet.

0 Kudos
PhilLarkin1
Regular Contributor

Hi, thanks for your reply. 

Looks like my problem is the oid_fields parameter should be set in this case. 

0 Kudos