FUNCTION  fGetNearestSpecObjIdEqType

Returns the specObjID 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 SpecClass table. This scalar function is used for matchups of external catalogs. It calls the fGetNearbySpecObjEq(@ra,@dec,@r), and selects the specObjID (a bigint). This can be called by a single SELECT from an uploaded (ra,dec) table.
An example:

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

Input and output parameters