Select to view content in your preferred language

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

04-24-2019 03:58 PM
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
MVP Esteemed Contributor

I just tried:

      , NULL as 'D'

and got:

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

0 Kudos
Regular Contributor

Hi, thanks for your reply. 

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

0 Kudos