How to Detect if a Value Contains at Least One Number in SQL Server

Sometimes you might need to search a database table for only those rows that contain at least one number in a given column.

Strictly speaking, numbers can be represented by words and other symbols, but for the purpose of this article, “number” means “numerical digit”.

Below is an example of how to use T-SQL to find rows that contain at least one number in SQL Server.

Continue reading

Fix Msg 8116 “Argument data type date is invalid for argument 1 of substring function” in SQL Server

If you’re getting SQL Server error Msg 8116 with text that reads Argument data type date is invalid for argument 1 of substring function, it’s because you’re passing the wrong data type to a function – in this case, the SUBSTRING() function.

You could also see the same error (Msg 8116) in many other contexts – it’s not limited to the SUBSTRING() function.

Continue reading

Fix Msg 8114 “Error converting data type varchar to numeric” in SQL Server

If you’re getting SQL Server error Msg 8114 that reads something like Error converting data type varchar to numeric, it’s probably because you’re trying to perform a data type conversion that fails due to the value not being able to be converted to the destination type.

It’s not because you can’t convert that type to the new type. It’s because of the value itself.

Continue reading