How to find place of decimal point in a decimal number in SQL Server using sql query
example:
123567.89
output:7
How to find place of decimal point in a decimal number in SQL Server using sql query
example:
123567.89
output:7
select charindex('.', cast(123567.89 as varchar))
declare @T decimal(38,1) = 1234567890123456789012345678901234567.1;
select charindex('.', cast(@T as varchar(40)));
如果只使用varchar,则默认大小为30;因此,它会失败。除此之外,如果这是在计算列中并且使用了 varchar,则默认大小为 1。
40 = 38 +“小数点”加“符号”
--select charindex('.', cast(@T as varchar)); -- Uncomment and it'll fail