?
Solved

LINKED SERVER: COLLATION / ENCODING Problem, PLEASE HELP!

Posted on 2003-11-23
10
Medium Priority
?
951 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
[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
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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
 
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 1500 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

777 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