Query: | SELECT lr.ReferenceUUID, lr.LocationUUID, lr.Start_Page, lr.End_Page, ref_pk.PKID, ref_pk.CorrectID, ref_pk.TableID, ref_pk.UUID, ref_pk.LegacyID, ref_pk.LegacyID2,
r.ReferenceID, r.ParentReferenceID, r.ReferenceTypeID, r.LanguageID, r.Year, r.Title, r.SecondaryTitle, r.Publisher, r.PlacePublished, r.Volume, r.NumberVolumes,
r.Number, r.Pages, r.InPages, r.Section, r.Edition, r.DatePublished, r.TypeWork, r.ShortTitle, r.Figures, r.StartDate, r.EndDate, r.URL, r.CheatCitation, r.CheatAuthors,
r.CheatFullAuthors, r.CheatCitationDetails, r.CheatSearchReference, loc_pk.PKID AS Expr1, loc_pk.UUID AS Expr2, loc_pk.FK_TableTypeID, loc_pk.CorrectID AS Expr3,
loc_pk.CheatSearchString, loc_pk.LegacyID AS Expr4, l.PK_LocationID, l.Location_name, l.FK_CountryID, l.Active, l.Abbreviation, l.x_location, l.y_location, l.map_name, l.GeoCoords.Lat as LocationDecimalLatitude, l.GeoCoords.Long as LocationDecimalLongitude, l.Echelon, l.FK_SubordID, l.location_description, l.height, l.width, l.y_rect_coords, l.x_rect_coords, l.SW_Bound_Lat, l.SW_Bound_Long, l.NE_Bound_Lat, l.NE_Bound_Long
FROM Location_join_Reference AS lr INNER JOIN
Taxonomer.dbo.PK AS ref_pk ON lr.ReferenceUUID = ref_pk.UUID INNER JOIN
Taxonomer.dbo.Reference AS r ON ref_pk.PKID = r.ReferenceID INNER JOIN
PK AS loc_pk ON lr.LocationUUID = loc_pk.UUID INNER JOIN
Locations AS l ON l.PK_LocationID = loc_pk.PKID
WHERE lr.ReferenceUUID IS NOT NULL
AND lr.LocationUUID = ?
ORDER BY lr.SortOrder |