简体   繁体   中英

TransactSQL: How to search table for ntext field starting with '-'

My ASP web page makes a SQL Server database call to try and find all rows that have a column that begins with the character '-'. (english is an ntext column)

I can execute the following query no problem in Enterprise Manager and get the desired results:

SELECT english FROM Translations WHERE english LIKE N'-%' ORDER BY english

But when I execute this query in my web page, I get a NOT FOUND (Recordset EOF). Any normal alpha char AZ works fine, but the '-' fails, even though there are records with the content beginning with that character.

I believe the '-' must be some sort of special char, but how do I tweak the query so that it returns the results it should?

Thanks Experts!

Thanks Martin & Gordon! That was it!

My suspicion would be the same as the issue here (the hyphen variant being searched for is a different variant than contained in the text. – Martin Smith yesterday

There are different types of dashes -- the most common being em-dash and en-dash. You are probably just searching for the wrong character. – Gordon Linoff yesterday

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM