QGIS and ESRI both like to see ObjectID (or an identity) in the data returned from a SQL query.
I use two methods to accomplish this.
1. Row_number() Over
Select ROW_NUMBER() OVER ( ORDER BY anydatacolumn) as ObjectID
However, ESRI doesnt like the returned data type so I convert it to an INT like so:
Select CONVERT(int,ROW_NUMBER() OVER (ORDER BY anydatacolumn)) as ObjectID
2. Newid() or NewSequentialId()
This will return a MS UUID (GUID) or sequential GUID. Apparently ESRI doesnt mind GUIDS as a ObjectID. I have yet to test with QGIS.