You do not need to interact with managed code, as you can use LIKE:
CREATE TABLE #Sample(Field varchar(50), Result varchar(50)) GO INSERT INTO #Sample (Field, Result) VALUES ('ABC123 ', 'Do not match') INSERT INTO #Sample (Field, Result) VALUES ('ABC123.', 'Do not match') INSERT INTO #Sample (Field, Result) VALUES ('ABC123&', 'Match') SELECT * FROM #Sample WHERE Field LIKE '%[^a-z0-9 .]%' GO DROP TABLE #Sample
As your expression ends with +
you can go with '%[^a-z0-9 .][^a-z0-9 .]%'
EDIT:
To make it clear: SQL Server doesn’t support regular expressions without managed code. Depending on the situation, the LIKE
operator can be an option, but it lacks the flexibility that regular expressions provides.
Related Posts:
- T-SQL split string
- How can I get column names from a table in SQL Server?
- MS SQL compare dates?
- MS SQL compare dates?
- Comma separated results in SQL
- Inserting multiple rows in a single SQL query? [duplicate]
- SQL Query with NOT LIKE IN
- T-SQL split string based on delimiter
- How do I perform an IF…THEN in an SQL SELECT?
- An attempt was made to access a socket in a way forbidden by its access permissions
- Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query
- Each GROUP BY expression must contain at least one column that is not an outer reference
- SQL Server : Arithmetic overflow error converting expression to data type int
- How to calculate percentage with a SQL statement
- What is the meaning of the prefix N in T-SQL statements and when should I use it?
- Query error with ambiguous column name in SQL
- Keeping it simple and how to do multiple CTE in a query
- How can I delete using INNER JOIN with SQL Server?
- Why use a READ UNCOMMITTED isolation level?
- Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query
- How to group by month from Date field using sql
- SQL – The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
- Is there a combination of “LIKE” and “IN” in SQL?
- How to get a date in YYYY-MM-DD format from a TSQL datetime field?
- How do I fix ‘Invalid character value for cast specification’ on a date column in flat file?
- What is the maximum characters for the NVARCHAR(MAX)?
- Get size of all tables in database
- How to format a numeric column as phone number in SQL
- sql query to return differences between two tables
- How do I format a number with commas in T-SQL?
- SQL: IF clause within WHERE clause
- To add server using sp_addlinkedserver
- How can I group by date time column without taking time into consideration
- How to select the last record of a table in SQL?
- SHOWPLAN permission denied in database ‘tempdb’. in sql server 2008
- Varchar invalid for Sum operator
- Selecting COUNT(*) with DISTINCT
- What is a stored procedure?
- LEFT JOIN vs. LEFT OUTER JOIN in SQL Server
- What do Clustered and Non-Clustered index actually mean?
- LEFT JOIN vs. LEFT OUTER JOIN in SQL Server
- How to drop a table if it exists?
- SQL Server: Difference between PARTITION BY and GROUP BY
- Self Join to get employee manager name
- How do I UPDATE from a SELECT in SQL Server?
- SQL query to select dates between two dates
- When should I use CROSS APPLY over INNER JOIN?
- SQL query to get the employee name and their manager name from the same table
- How can I do an UPDATE statement with JOIN in SQL Server?
- Rename column SQL Server 2008
- Function to Calculate Median in SQL Server
- Efficiently convert rows to columns in sql server
- How to delete duplicate rows in SQL Server?
- The SQL OVER() clause – when and why is it useful?
- Update multiple columns in SQL
- Function to Calculate Median in SQL Server
- How do I escape a single quote in SQL Server?
- SQL Server IF EXISTS THEN 1 ELSE 2
- What is the use of GO in SQL Server Management Studio & Transact SQL?
- SQL Query with SUM with Group By
- SQL Server Management Studio, how to get execution time down to milliseconds
- How do I escape a single quote in SQL Server?
- IDENTITY_INSERT is set to OFF – How to turn it ON?
- SQL update from one Table to another based on a ID match
- How to drop all tables from a database with one SQL query?
- Optimistic vs. Pessimistic locking
- Column name or number of supplied values does not match table definition
- SQL Server FOR EACH Loop
- The target principal name is incorrect. Cannot generate SSPI context
- Query comparing dates in SQL
- The EXECUTE permission was denied on the object ‘xxxxxxx’, database ‘zzzzzzz’, schema ‘dbo’
- BCP error “Unable to open BCP host data-file”
- How can I clone an SQL Server database on the same server in SQL Server 2008 Express?
- Delete all the records
- Each GROUP BY expression must contain at least one column that is not an outer reference
- SQL Server : error converting data type varchar to numeric
- How to drop all tables from a database with one SQL query?
- Sql Server string to date conversion
- How to find sum of multiple columns in a table in SQL Server 2005?
- Check if table exists in SQL Server
- Invalid length parameter passed to the LEFT or SUBSTRING function
- Conversion failed when converting from a character string to uniqueidentifier – Two GUIDs
- Operand type clash: int is incompatible with date + The INSERT statement conflicted with the FOREIGN KEY constraint
- How can I truncate a datetime in SQL Server?
- Find all tables containing column with specified name – MS SQL Server
- DateTime2 vs DateTime in SQL Server
- SQL Server Insert if not exists
- CREATE TABLE IF NOT EXISTS equivalent in SQL Server
- How can I import an Excel file into SQL Server?
- SQL Server: Invalid Column Name
- sql server invalid object name – but tables are listed in SSMS tables list
- SQL Connection Error: System.Data.SqlClient.SqlException (0x80131904)
- SQL Server String or binary data would be truncated
- How to parse XML data in SQL server table
- Search text in stored procedure in SQL Server
- How to convert SQL Server’s timestamp column to datetime format
- What is the equivalent of ‘describe table’ in SQL Server?
- Arithmetic overflow error converting expression to data type datetime. (while displaying date time..)
- Error converting data type varchar to float
- What is the Oracle equivalent of SQL Server’s IsNull() function?