开发者

Query to find columns that end with percent symbol %

开发者 https://www.devze.com 2023-04-12 15:57 出处:网络
What T-SQL q开发者_如何学编程uery I should use to find out all rows that have column1 ending with %? I am using SQL SERVER 2000. Sample data in column1:

What T-SQL q开发者_如何学编程uery I should use to find out all rows that have column1 ending with %? I am using SQL SERVER 2000. Sample data in column1:

column1
-------
100px
100%  <- THIS ROW
200px
200%  <- THIS ROW
300px
300%  <- THIS ROW


SELECT * FROM table
WHERE column1 LIKE '%[%]' 


DECLARE @TMP TABLE(COL VARCHAR(MAX))
INSERT INTO @TMP VALUES ('100%')
INSERT INTO @TMP VALUES ('100px')

SELECT * FROM @TMP WHERE COL LIKE '%[%]' 

Please check out question Escape a string in SQL Server so that it is safe to use in LIKE expression for more examples of escaping special characters.

The official documentation is in the MSDN article for the LIKE operator (SQL Server 2000).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号