Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

[RESOLVED] SQL Syntax that I'm just not getting right...

$
0
0
Would you be so kind as to run this query and explain to me why I am not getting the result I'm expecting, which is LineNumberAsDecimal 1.1, versus LineNumberAsDecimal 1.10?
I must be doing something really stupid?

Code:

DECLARE @lineNumber nvarchar(4)
SELECT @lineNumber = '1.1'
SELECT @lineNumber,
LEN(substring(@lineNumber, charindex('.', @lineNumber)+1, 2)),
CASE
        WHEN ((LEN(substring(@lineNumber, charindex('.', @lineNumber)+1, 2))) = 1)
        THEN  CONVERT(decimal(4,1), @lineNumber)
        ELSE CONVERT(decimal(4,2), @lineNumber)
END as LineNumberAsDecimal


Viewing all articles
Browse latest Browse all 2918

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>