Salman Arshad
Salman Arshad

Reputation: 272106

Query to find columns that end with percent symbol %

What T-SQL query 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

Upvotes: 1

Views: 3164

Answers (2)

Gibron
Gibron

Reputation: 1369

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).

Upvotes: 3

Highly Irregular
Highly Irregular

Reputation: 40539

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

Upvotes: 4

Related Questions