Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Trouble casting a string as a float value and storing in a new variable

$
0
0

When I try to create my stored procedure, I get an error saying there is a problem, which I've narrowed down to the part where I try to set the value of a float variable based on the value of a different text variable.  Any comments on what I'm doing wrong?

DECLARE @txtVar nvarchar(4000)

DECLARE @floatVar float

....

(code gets the value of @txtVar and sets it)

...

(now I'm trying to test if the value of @txtVar is numeric, and if it is, to set the @floatVar as that numeric value)

IF ISNUMERIC(@txtVar) = 1

BEGIN

    SET @floatVar = CAST(@txtVar as float)

END


Gina


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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