1

I am trying to convert an Oracle query to a SQL Server and facing an issue. Can you please help me ?

Oracle Query:

select ORA_HASH(SYS_GUID()) as SEGMENTID from my_Table

I am looking for a function which is equivalent to ORA_HASH() function in SQL Server. I was searching in google and found that HASHBYTES() function is the one which works as ORA_HASH in SQL Server. But when I tried to use, the return value of this is Hexa decimal and on the other hand, ORA_HASH is returning an integer.

Can you please help me in proving the equivalent function to ORA_HASH in SQL Server which works same as ORA_HASH ?

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
Sree Bhanu
  • 79
  • 2
  • 6
  • 1
    "Found that HASHBYTES works as ORA_HASH" is highly dubious. A quick Google search shows that HASHBYTES uses one of the "standard" hashing algorithms. By contrast, ORA_HASH uses a **proprietary** algorithm, known only to Oracle. So, the next question is, do you need your SQL Server solution to be compared in any way to anything coming from Oracle? If not, why do you need to refer to Oracle at all? –  Oct 10 '17 at 05:25

1 Answers1

2

You shall try CHECKSUM which as per doc is intended for use in building hash indexes. https://learn.microsoft.com/en-us/sql/t-sql/functions/checksum-transact-sql

Optional
  • 4,387
  • 4
  • 27
  • 45