Skip to main content

Posts

Showing posts from 2018

Quick Character Script for SQL Server CHAR()

Q uick post - I had to find and replace crazy characters in one of our CHAR, NCHAR , and NVARCHAR data types.  Since there are only 256 characters, you'll only get that many results DECLARE @i INT  = 0 DECLARE @c TABLE ( char_number INT , char_desc NVARCHAR (1)) WHILE @i < 310 BEGIN  INSERT INTO @c(char_number, char_desc) SELECT @i AS eye_d, CHAR (@i) AS char_desc SET @i = ( ISNULL (@i,310) + 1)     IF CHAR (@i) IS NULL SET @i = 310  END  SELECT * FROM @c