?
Solved

SQL Server CONVERT displaying squares

Posted on 2010-09-14
12
Medium Priority
?
394 Views
Last Modified: 2013-11-25
I am doing a convert on a BLOB, on one machine it displays the text fine, on another, it is filling the CONVERTed field with squares. SQL-CONVERT-COMMAND.doc
0
Comment
Question by:ourguru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 41

Expert Comment

by:ralmada
ID: 33673003
try converting to nvarchar rather than varchar alone
 
0
 

Author Comment

by:ourguru
ID: 33673069
ralmada,

Made it worse, now field begins with squares and only has a letter here and there with squares all throughout.

0
 
LVL 41

Expert Comment

by:ralmada
ID: 33673083
check the collation in both databases, make sure you are using the same collation
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 41

Expert Comment

by:ralmada
ID: 33673129
also try using nvarchar(max) rather than nvarchar(8000)
0
 

Author Comment

by:ourguru
ID: 33673210
No go on the nvarchar(max), same output.

I am accessing the same database, just from different machines.  I am using SQL BIDS, not sure if that helps.
0
 
LVL 41

Expert Comment

by:ralmada
ID: 33673344
Ok, that sounds like the fonts installed on the machines. A square/rectangle is the default glyph displayed when the font doesn't
have access to the right characters.
0
 

Author Comment

by:ourguru
ID: 33673357
I believe it is either filling with CR or LF or both.
when i export to excel, the field is full of extra CRs
0
 
LVL 41

Expert Comment

by:ralmada
ID: 33673507
well, you can get rid of the CR LF by doing
replace(replace(convert(varchar(8000), convert(binary(8000), yourcol)), char(13), ''), char(10), '')
0
 

Author Comment

by:ourguru
ID: 33673545
No help.  Could it be filling to the (8000)?
0
 

Author Comment

by:ourguru
ID: 33673570
Ok,  i just changed the convert(binary(8000) to (10) just to see and that works.  Is there a way to get the length first so that it doesn't fill to 8000?
0
 
LVL 41

Accepted Solution

by:
ralmada earned 2000 total points
ID: 33673587
ok, then use varbinary instead of binary
converT(varbinary(8000),yourcol)
0
 

Author Comment

by:ourguru
ID: 33674344
ralmada,

That did it!!!  Thank you very much!!!
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question