Solved

LINKED SERVER: COLLATION / ENCODING Problem, PLEASE HELP!

Posted on 2003-11-23
10
921 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

776 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