Occasionally Data analyst may fall in a situation, where they need to identify records holding special characters or only the records having no special records at all. It is fairly simple to identify such records.
Let us start with creating a simple table and inserting both type of character values.
Now logically, if you try to convert a NVARCHAR value to VARCHAR, SQL will fail to translate it and convert the special characters into “?”.
We use the same logic to identify our records.
To find only the Non-Unicode Character use below query. Only the records which are successfully converted into varchar will be able to match the original column.
Where CONVERT(varchar(20),CompanyName) = CompanyName
To identify only the records with special character just replace = with <>
Where CONVERT(varchar(20),CompanyName) = CompanyName.
Let me know your views, questions or any other method of doing same. If you are novice and want to know more detail about VARCHAR and NVARCHAR, Drop your query in comments i will pick that up for future.