-1

I'm generating unique identifier values using NEWID(). The problem is sometimes values are generating like "65687519-E612-4B86-A8D8-F44E53DD6EDC" The first part of unique identifier value is all numeric characters(65687519). This is creating some problem in HTML. What is the way to solve the problem? Still I couldn't resolve the issue. Anybody please help.

Gopal Biswas
  • 387
  • 1
  • 5
  • 32

2 Answers2

0

are you looking for something like:

SELECT ABS(CAST(CAST(NEWID() AS VARBINARY(5)) AS Bigint)) as UNIQUE_NUMERIC

don't hate google. google is your friend! similar problems already posted & answered like How to get numeric random uniqueid in SQL Server

Esteban P.
  • 2,739
  • 2
  • 24
  • 42
0

If you don't really care about the identifier and just want it to be unique you can prepend some predetermined string to it (which won't harm its uniqueness, of course). E.g.:

SELECT 'id' + CAST(newid() AS VARCHAR(36)) AS new_id
Mureinik
  • 277,661
  • 50
  • 283
  • 320