HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How can I view special characters in SQL Server 2012 Management Studio grid view?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
studiocan2012gridserversqlviewmanagementspecialhow

Problem

In a SQL Server 2012 database, I have a log table where I log SQL queries executed by a VB.NET application.

The field is defined as nvarchar(MAX)

In Microsoft SQL Server Management Studio, when I go to the table and do "Edit All Rows",
on one line I see spaces in the end of the text

But when I enter my cursor in the line to edit it (not touching anything, before I even start editing), the spaces disappear (along with the trailing quote)

And when I go to New Query and execute the same query

SELECT LOGID, LogDate, SqlLog 
FROM ezber_SQL_LOG 
WHERE (LOGID = 1604))


I get the result without the spaces and the trailing quote:

So my guess is that there are special characters in the data (line breaks, tabs or something like that), but how can I find out for sure and know what they are?

Solution

I found viewing the data as binary was the way to go for me:

SELECT @String as MyString, CAST(@String as varbinary(max)) MyString_In_Hexidecimal;


I found an ASCII table then helped decipher what was in the string.

Code Snippets

SELECT @String as MyString, CAST(@String as varbinary(max)) MyString_In_Hexidecimal;

Context

StackExchange Database Administrators Q#55329, answer score: 4

Revisions (0)

No revisions yet.