Solved

LINKED SERVER: COLLATION / ENCODING Problem, PLEASE HELP!

Posted on 2003-11-23
10
912 Views
Last Modified: 2007-12-19
I have a linked server to PostgreSQL on my SQL 2K Server.
While trying to retrieve data from the linked server without using any collation I get "?????" instead of data. (it's because the data stored on PostgreSQL is in Hebrew).

If I use something like this:
SELECT myfield COLLATE SQL_EBCDIC273_CP1_CS_AS as myfield FROM OPENQUERY(linked_server, ....)
then I can see returned data.

BUT if I do the same with FOR XML AUTO at the end (i.e. SELECT myfield COLLATE SQL_EBCDIC273_CP1_CS_AS as myfield FROM OPENQUERY(linked_server, ...)  FOR XML AUTO) I continue receiving "?????".

1. Is it possible to set COLLATION GLOBALLY for all returned fields by PostgreSQL?
2. How to retrieve DATA using FOR XML clause (in this specific issue with collation conflicts)

Thanks.
0
Comment
Question by:bibarius
  • 6
  • 4
10 Comments
 
LVL 9

Expert Comment

by:miron
ID: 9808129
my first turn would be to try something easy, like this

select * from
(SELECT myfield COLLATE SQL_EBCDIC273_CP1_CS_AS as myfield FROM OPENQUERY(linked_server, ...) ) as dt for xml auto

0
 

Author Comment

by:bibarius
ID: 9808175
Hi Miron!

I tried what you wrote. It looks so:
select fname from (
select fname COLLATE SQL_EBCDIC273_CP1_CS_AS as fname from openquery(secureshop, 'select fname from userdb order by clubid desc limit 10') ds) as ds
for xml auto

.. but same result.... I get "?????" after I use FOR XML AUTO...
0
 
LVL 9

Expert Comment

by:miron
ID: 9808212
well, it looks like SQL Server provides for setting up collation for a linked server this way

sp_serveroption @server = 'secureshop'
    ,@optname =  'collation name'
    , @optvalue = 'SQL_EBCDIC273_CP1_CS_AS'

I am not sure that it would help with XML AUTO though, one more to go

--cheers
0
 

Author Comment

by:bibarius
ID: 9808229
I'v already tried this...
It doesn't help...
0
 
LVL 9

Expert Comment

by:miron
ID: 9808353
on the other hand, could you try something like this

setup linked server collation to SQL_EBCDIC273_CP1_CS_AS

then on the local SQL Server from windows command prompt execute

bcp "select * from ( secureshop, 'select fname from userdb order by clubid desc limit 10' ) as dt for xml auto" queryout C:\test.xml -c -C 1252  -T

and then try to view the file C:\test.xml in the IE. You will need to edit xml root node if the query returns multiple rows.


--cheers
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 9

Expert Comment

by:miron
ID: 9808408
In that post

"
I'v already tried this...
It doesn't help...
"

did you mean it misses to help with XML or it does not help completely. Also, if none of the above helped, could you post the result of this query


select top 1  convert( binary(256), fname ) from  ( select fname COLLATE SQL_EBCDIC273_CP1_CS_AS as fname from openquery(secureshop, 'select fname from userdb order by clubid desc limit 10') ds ) as dt
0
 

Author Comment

by:bibarius
ID: 9808437
None of the above helped.

The result of your last query is:
0xF9ECE5EEE9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0
 
LVL 9

Accepted Solution

by:
miron earned 500 total points
ID: 9808942
do you have any special fonts installed for rendering Hebrew
0
 

Author Comment

by:bibarius
ID: 9808958
Hi Miron!

I just finished dealing with this problem.
Everything fixed after I rebuilt the server and set other collation.

Thank you for your help (willing to help) :-)
You earned your points :-)
0
 
LVL 9

Expert Comment

by:miron
ID: 9809018
Hi bibarius,

            thanks for being generous :)

--cheers
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now