When I define a proxy table from SQL Anywhere (12) through ODBC to an MS SQL/Server table that contains a uniqueidentifier, the value of the UUID is returned to ISQL with the bytes flipped around. Specifically, the Endianness difference from SQL/Server to SQL Anywhere is ignored.

Various articles around the net describe the different UUID representations, but getting different results from SQL/Server's "SELECT someuuidcolumn FROM sometable" and the same query through an SQL Anywhere proxy table query seems pretty much wrong - e.g., '00013c07-e7f5-4033-bdbf-b34d6391f445' vs '073c0100-f5e7-3340-bdbf-b34d6391f445'. In particular, having a '4' at the start of the third group of digits identifies a UUID as a "V4" GUID and really shouldn't be arbitrarily flipped around, regardless of how the UUID is stored in the database. Can someone say if it's an ODBC issue, but even then, shouldn't SQL Anywhere deal with it? (I believe the problem occurs with SQL Anywhere 16 too, but I haven't tried it myself.)

asked 16 Jul '14, 23:34

DougMWat's gravatar image

DougMWat
1365512
accept rate: 0%


From my research it would appear you can see this if your MS GUID is being bound as a binary value.

Whereas Microsoft stores their GUIDs as little-endian binary values, the standard for UUIDs is Most Signifiant Byte first (aka big-endian) or as describe in the RFCs for this "network byte order". See a reference to RFC 4122 for the sections on "4.1.2. Layout and Byte Order", and the many references to the terms "network byte order" and "endian".

SQL Anywhere implements the UUID statndard internally. This should not be a problem and should map correctly when interchanging data with Microsoft databases if the data types being used are proper UUID and not raw binary values.

So this is most likely failing if the proxy table is defined with a raw binary(n) instead of a UUID. You should be able to verify if this is your issue by issuing, in DBISQL, the statement

DESCRIBE TABLE <your proxy="" table="">

and noting if the column in question is of type binary(16, say) or type UUID.

The solution should be as simple as explictly defining the proxy as having the correct type. Let us know if this helps.

permanent link

answered 18 Jul '14, 09:33

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
7.3k35107
accept rate: 32%

Thanks for looking into this Nick, I very much appreciate it, however I don't think it's the problem. Using DESCRIBE TABLE from DBISQL and Sybase Central ("Columns" tab) as well as viewing the "Columns" attribute in MS SQL Server Management Studio, these columns are "uniqueidentifier" across the board.

FYI my versions are a little dated - SQL Anywhere 12 (12.0.1.3967) and SQL Server 2008 R2, all running on Windows 7 Enterprise ("MS Windows Version 6.1 (Build 7601: Service Pack 1)") so perhaps some updating is in order. We have SQL Anywhere 16 on one system, so I'll likely try it there and possibly build a small example case too.

(18 Jul '14, 12:10) DougMWat

Thank you for reporting this issue. I agree that there is something more that SQL Anywhere can do to properly handle GUIDs from SQL Server. We will investigate further and provide a fix.

permanent link

answered 18 Jul '14, 14:34

Karim%20Khamis's gravatar image

Karim Khamis
5.7k53870
accept rate: 40%

1

There are three ways to do any one thing: the right way, the wrong way and the Transact SQL way :)

(18 Jul '14, 17:00) Breck Carter
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×145
×70
×7
×4

question asked: 16 Jul '14, 23:34

question was seen: 4,004 times

last updated: 18 Jul '14, 17:00