Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Argument data type numeric is invalid for argument 1 of substring function

I get the following message with this code

case when substring(New_Limit,11,1)=' ' then '0'+substring(New_Limit,1,10)

The 'then' bit is meant to concat the 0 and substring. Any help?

like image 380
user1296762 Avatar asked Dec 05 '22 13:12

user1296762


2 Answers

This means that your New_Limit variable is a numeric value. You may want to put a CAST to (n)varchar around it.

like image 99
Gert Arnold Avatar answered Dec 07 '22 03:12

Gert Arnold


You try to cast it to a string type (varchar) first:

SUBSTRING(CAST(New_Limit AS varchar(38)), 11, 1)
like image 38
Dang Thinh Avatar answered Dec 07 '22 03:12

Dang Thinh