FUNCTION  fGetNearestObjIdEqType

Returns the objID of the nearest photPrimary of type @t within @r arcmin

ra, dec are in degrees, r is in arc minutes.
t is an integer drawn from the PhotoType table.
popular types are 3: GALAXY, 6: STAR
others: 0: UNKNOWN, 1:COSMIC_RAY 2: DEFECT, 4: GHOST, 5: KNOWNOBJ, 7:TRAIL, 8: SKY This scalar function is used for matchups of external catalogs. It calls the fGetNearbyObjEq(@ra,@dec,@r), and selects the objId (a bigint). This can be called by a single SELECT from an uploaded (ra,dec) table.
An example:

SELECT id, ra,dec, dbo.fGetNearestObjIdEqType(ra,dec,3.0,6) as objId
FROM #upload
WHERE dbo.fGetNearestObjIdEqType(ra,dec,3.0,6) IS NOT NULL

Input and output parameters