Background
I was using SQL Server Management Studio ( SSMS ) and experienced an unusual error.
Let us cover it succinctly.
Query
select a = 1 union select b = 2 union all select c = 3 union all select d = 4 union all select e = 5
Error Message
Image
Textual
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 5 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 9 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 13 Incorrect syntax near ' '. Msg 102, Level 15, State 1, Line 17 Incorrect syntax near ' '.
Troubleshooting
Online Tools
Outline
Here are some online tools for detecting hidden characters
- soscisurvey.de
- View non-printable Unicode characters
Link
- View non-printable Unicode characters
Tools
soscisurvey.de
View non-printable Unicode characters
Image
Explanation
- Hard Space
Desktop Tools
Outline
Here are some desktop tools for managing hidden characters
- notepad++
Tools
notepad++
Search specific character – Count
Steps
- Launch Notepad++
- Load File
- Access Find Dialog
- In Find Dialog
- Find What:-
- In the find what text box please enter “\xa0“
- Search Modes:-
- Normal
- ( Matches will not be found )
- Extended
- ( Matches are found )
- Regular Expression
- ( Matches are found )
- Normal
- Count Button
- Access the Count Button to initiate the counting
- Find What:-
- In Find Dialog
Image
Explanation
- We counted 5 matches
Search specific character – Find/Next
Steps
- Launch Notepad++
- Load File
- Access Find Dialog
- In Find Dialog
- Find What:-
- In the find what text box please enter “\xa0“
- Search Modes:-
- Normal
- ( Matches will not be found )
- Extended
- ( Matches are found )
- Regular Expression
- ( Matches are found )
- Normal
- “Find Next” Button
- Access the “Find Next ” Button to initiate the counting
- Find What:-
- In Find Dialog
Image
Explanation
- We were able to find the instances where the special character was in use
Search specific character – Replace
Steps
- Launch Notepad++
- Load File
- Access Find Dialog
- In the Find Dialog, please access the “Replace” tab
- Find What:-
- In the find what text box please enter “\xa0“
- Replace What:-
- In the replace with text box, please enter the a single space bar or multiple space bars
- Search Modes:-
- Normal
- ( Matches will not be found )
- Extended
- ( Matches are found )
- Regular Expression
- ( Matches are found )
- Normal
- “Replace All” Button
- Access the “Replace All” Button to replace all “hard spaces“
- Find What:-
- In the Find Dialog, please access the “Replace” tab
Image – Find Replace – Initial
Image – Find Replace – Post Changes
Explanation
- We were able to replace all the hard spaces
Test Environment
This is a constructed test.
Here are my pre-requisites.
- SQL Server Version
- Reproducible
- SQL Server v2005
- SQL Server v2008 R2
- Remediated
-
- Microsoft SQL Server 2012 (SP1)
-
- Reproducible
- File Encoding
- UTF-8
Source Code
GitHub
Gist
sqlServer – file – unicode – contains – nobreakspace
GitLab
sqlServer – file – unicode – contains – nobreakspace
Referenced Work
- La De Du
- How to Enter a No-Break Space on Windows
Link
- How to Enter a No-Break Space on Windows
- soscisurvey.de
- Tools
- View Characters
Link
- View Characters
- Tools
- FileFormatInfo
- Unicode Character ‘NO-BREAK SPACE’ (U+00A0)
Link
- Unicode Character ‘NO-BREAK SPACE’ (U+00A0)
- Notepad++
- Scintilla
- #974 Display of “special” whitespaces
Link
- #974 Display of “special” whitespaces
- David Klempfner
- The Zero Width Space
Link
- The Zero Width Space
- IT Support Guides
- Classic Editor / TinyMCE – How to automatically insert Non-Breaking Space using Ctrl + Shift + Space
Link
- Classic Editor / TinyMCE – How to automatically insert Non-Breaking Space using Ctrl + Shift + Space