|
|
-
Zibi Commented 9 Months ago through Blogs | 1 Point
@jcelko: 5 post before your sample is solution given by Leszek that is working the same way...
|
-
Zibi Commented 12 Months ago through Blogs | 1 Point
Hello,
so below two more generic solutions based on tally table. The first in pure sql, second with a little xml support. Solutions base on normalisation (converting to decimal) and comparing (text or float). Both solutions are single queries.
|
-
Zibi Commented 12 Months ago through Blogs | 1 Point
Hello,
not happy with data like below
set @s= '2.202 3.0 31'
returns:
2.2020 30 4.0000 2.202 3.0 31
2.202000 30 4.0000 2.202 3.0 31
and should return nothing
...
|
-
Zibi Commented 12 Months ago through Blogs | 1 Point
Hello,
another approuch using xml (splitting numbers, normalizing and creating key from them - those action perform in searched string and in the table. Next seeking prepared key in the table)
regards
Zibi
;with cte01...
|
-
Zibi Commented 12 Months ago through Blogs | 1 Point
Hello,
next approuch
regards
Zbigniew
select [sum_of_digits]=cast(cast(
cast(replicate('',len(@i))+''+cast(@i as varchar)+'' as xml).query(
...
|
-
Zibi Commented 12 Months ago through Blogs | 1 Point
Hello,
another xml approuch
regards
Zbigniew
declare @i int, @sql varchar(8000)
set @i=798273
select [sum_of_digits]=cast(
cast(
cast(''+cast(@i as varchar...
|
-
Zibi Commented 12 Months ago through Blogs | 1 Point
Hello, this below is proof of such errors
select [sum_of_digits]=
cast(replace(cast(cast(
replace(
replace(
replace(
replace(
replace(
...
|
-
Zibi Commented 12 Months ago through Blogs | 1 Point
Method 4 : Using xml (without variables)
select [sum_of_digits]=
cast(cast(cast(
replace(
replace(
replace(
replace(
replace(
...
|