SQL Server - LIKE Operator Works When Searching Partial String But Not Whole String -
i experiencing issue sql server database that, truthfully, i'm unsure how describe. therefore, try demonstrate it, best can.
i have table containing several rows value in [meter name] column
electric meter #140002054 acct.2013147 house, south mall service &&parking lot now, when run following query, result expect.
select distinct [meter name] last_pm_export [meter name] 'electric meter #140002054 acct.2013147 house, south mall service%' note using % wildcard, cutting off search pattern after word "service". following result.
expected result using partial string
again, expect. no problem.
now, observe happens when extend pattern include space comes after word "service".
select distinct [meter name] last_pm_export [meter name] 'electric meter #140002054 acct.2013147 house, south mall service %' unexpected result using partial string
as can see, query returns no results. have tried querying entire string, is, copied directly out of table.
select distinct [meter name] last_pm_export [meter name] 'electric meter #140002054 acct.2013147 house, south mall service &&parking lot' the result same query above. no results.
i cannot think of reason should happening. flies in face of how understand like operator work. i've consulted our in-office person, , agrees unusual.
again, know isn't description of problem, demonstration suffice. also, apologies not being able share table or database more fully, cannot reasons of confidentiality.
any assistance appreciated. thank you.
not answer, comment... please confirm, exact scenario of issue? can check out, both selects come right rows...
declare @mockup table([meter name] varchar(1000)); insert @mockup values('electric meter #140002054 acct.2013147 house, south mall service &&parking lot') ,('electric meter #140002054 acct.2013147 house, south mall service &&some other') ,('different'); --without blank
select * @mockup [meter name] 'electric meter #140002054 acct.2013147 house, south mall service%'; --with blank
select * @mockup [meter name] 'electric meter #140002054 acct.2013147 house, south mall service %'; might there more, reduced brevity? able change above mock-up in order make issue reproduceable?
Comments
Post a Comment