Press "Enter" to skip to content

Null Bytes In Text Strings

Jay Robinson has null bytes he wants to remove from Unicode strings:

As it turns out, when you have a character string in SQL Server that contains character 0x000, it really doesn’t know what to do with it most of the time, especially when you’re dealing with Unicode strings.

I did track down http://sqlsolace.blogspot.com/2014/07/function-dbostripunwantedcharacters.html, but I generally try to avoid calling UDF’s in my queries.

Jay’s got an answer which works, so check it out.  Also, I second the use of the #sqlhelp hashtag.  There’s a great community watching that hashtag.