Thursday, February 16, 2012

Cannot get "LIKE" to Work in My Query

Excel 2003. SQL Server 2000. I have an Excel module that grabs some data
from an SQL database using an ADODB connection. If I use the following in
the SQL query, it returns no data:
(WHERE INVOICENUMBER LIKE 'MS*')
However, if I use the following, I get all the data I expect:
(WHERE INVOICENUMBER>='MS' AND INVOICENUMBER<='MS9999999999999')
What am I doing wrong? How may I properly use the LIKE phrase? Thanks for
any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.orgUse % instead of *.
"Chaplain Doug" <ChaplainDoug@.discussions.microsoft.com> wrote in message
news:2433FFE0-85C8-419F-9EB8-2C3302E5058B@.microsoft.com...
> Excel 2003. SQL Server 2000. I have an Excel module that grabs some data
> from an SQL database using an ADODB connection. If I use the following in
> the SQL query, it returns no data:
> (WHERE INVOICENUMBER LIKE 'MS*')
> However, if I use the following, I get all the data I expect:
> (WHERE INVOICENUMBER>='MS' AND INVOICENUMBER<='MS9999999999999')
> What am I doing wrong? How may I properly use the LIKE phrase? Thanks
for
> any help.
> --
> Dr. Doug Pruiett
> Good News Jail & Prison Ministry
> www.goodnewsjail.org|||in SQL, the wildcard character is % not *. Single character wildcard is _
instead of ?
"Chaplain Doug" <ChaplainDoug@.discussions.microsoft.com> wrote in message
news:2433FFE0-85C8-419F-9EB8-2C3302E5058B@.microsoft.com...
> Excel 2003. SQL Server 2000. I have an Excel module that grabs some data
> from an SQL database using an ADODB connection. If I use the following in
> the SQL query, it returns no data:
> (WHERE INVOICENUMBER LIKE 'MS*')
> However, if I use the following, I get all the data I expect:
> (WHERE INVOICENUMBER>='MS' AND INVOICENUMBER<='MS9999999999999')
> What am I doing wrong? How may I properly use the LIKE phrase? Thanks
> for
> any help.
> --
> Dr. Doug Pruiett
> Good News Jail & Prison Ministry
> www.goodnewsjail.org

No comments:

Post a Comment