When i am trying the below query, getting different answers. DECLARE @num2 decimal(26,10) = 152.00685100 SELECT PARSENAME(@num2,1) --- Output : 0068510000 SELECT PARSENAME(cast(@num2 as DOUBLE PRECISION),1) ---- Output : 007
what is the difference in these query. What is doing in depth.
I just try to convert to NVARCHAR/VARCHAR and try. that also getting different result
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Version Independent ID: 26fa833a-91d2-88d7-7840-4e71b41b2826
@aksajith This issue has nothing to do with PARSENAME. You are passing in numbers to a function which accepts a string input parameter. The difference in what you are seeing is happening in the implicit conversion from the particular number type into NVARCHAR. You can see this more clearly if you remove PARSENAME and just do the conversion explicitly:
You might also want to check out the STR built-in function, as it converts number types into VARCHAR.
Also, I highly recommend using FLOAT instead of the synonym DOUBLE PRECISION as a lot of people might not immediately know that "DOUBLE PRECISION" == FLOAT. In almost 20 years of using SQL Server, I have never once seen someone use DOUBLE PRECISION (not in code, or a book, blog post, article, forum, chat room, etc).