Monday, July 14, 2008

SQL Tips: Using Regular Expressions in SQL Query


One more; courtesy of our greate DBA - K. Fridman:

DECLARE @RegExp VARCHAR(100)
SET @RegExp = '%[^a-zA-Z0-9._-]%'
SELECT *
FROM Clients
WHERE PATINDEX(@RegExp, UserName) > 0


No comments: