Search table query won't work on field in view made with COALESCE function
We have a burials table with first name, middle name, last name and former (maiden) name as separate fields, and we'd like out users to be able to simply type in a person's full name, rather than type in a last name etc and having to look through a list. My supervisor created a view with a FullName field built from the other name fields using COALESCE:
SELECT OBJECTID, LocalID, FirstName, MiddleName, FormerName, LastName, REPLACE(REPLACE(RTRIM(COALESCE (FirstName + ' ', '') + COALESCE (MiddleName + ' ', '') + COALESCE ('(' + FormerName + ') ', '')
+ COALESCE (LastName + ' ', '')), SPACE(2), SPACE(1)), '() ', '') AS FullName, BurialType, Gender, Age, CONVERT(varchar, DateOfBirth, 101) AS DateofBirth, BirthYear, CONVERT(varchar, DeathDate, 101) AS DeathDate,
CONVERT(varchar, BurialDate, 101) AS BurialDate, BurialYear, CauseofDeath, PlaceOfDeath, Religion, FuneralHome, ResidentIndicator, VeteranIndicator, VeteranBranch, VeteranEra, RelationToOwner, Source, DocLinks,
Comments, GlobalID, CremationIndicator
FROM Parks.CEMETERYBURIALSV2
When I use the query:
SELECT * FROM ProductionSDE.Parks.VWCemeteryBurialsV2 WHERE FullName LIKE @Name
In the search table, I don't get any results. If I replace FullName with LastName or any of the other name fields in the WHERE clause I can get results. The FullName does display in query results made with the other fields, I just don't seem to be able to query the FullName field itself. Is this a known limitation or is there a work around?
0
Please sign in to leave a comment.
Comments
0 comments