本文介紹了從字符串 TSQL 中獲取數(shù)字的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
將帶有數(shù)字的 NVARCHAR 拆分為 int 的最簡單方法是什么?例如123"中的 1、2 和 3.
What is the easiest way to split NVARCHAR with numbers into int's? For example 1, 2 and 3 from "123".
推薦答案
注意,您也可以使用遞歸 CTE 來做到這一點:
As a note, you can also do this with a recursive CTE:
with val as (
select '123' as val
),
cte as (
select left(val, 1) as c, substring(val, 2, len(val)) as rest
from val
union all
select left(rest, 1), substring(rest, 2, len(rest))
from cte
where rest <> ''
)
select c
from cte;
這篇關(guān)于從字符串 TSQL 中獲取數(shù)字的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!