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.
Asked
Active
Viewed 598 times
-1
-
3Then the problem is your code and not the `NEWID()` function. – juergen d Jun 19 '17 at 10:05
-
I'm generating the value using NEWID().There is nothing to do with coding. @ juergen d – Gopal Biswas Jun 19 '17 at 10:11
-
When you have a problem with the output then there is something wrong with your code right there. `NEWID()` returns always valid output. – juergen d Jun 19 '17 at 10:12
-
I'm generating the value using NEWID() inside a stored procedure. So I don't think there is nothing to do with coding @ juergen d – Gopal Biswas Jun 19 '17 at 10:15
2 Answers
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,789
- 2
- 27
- 43
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
- 297,002
- 52
- 306
- 350