I want to cast or convert newid() output to decimal (with minimum space required)
So far I did this :
SELECT CAST( '0x'+REPLACE(CAST(NEWID() AS VARCHAR(50)), '-', '' ) AS DECIMAL(38,0) )
But I'm getting this error :
Error converting data type varchar to numeric.
Searched a lot but getting frustrated, came here to find some help.
Many thanks in advance.
update : decimal(8,0) became decimal(38,0) and still getting the same error.