問題描述
我想像這樣使用我的功能
I want to use my function like this
SELECT BaseSplit(line,';') FROM table
有沒有辦法做到這一點(diǎn)???
is there any way to do that ???
我嘗試了 CROSS APPLY 但它不是我想要的
I try CROSS APPLY but it not what I want
我的表格有一列名為 line
My table has a column named line
line
______
15;2;5
NULL
10;3;6
我想將此列拆分為像
15
2
5
Null
10
3
6
是否有自動(dòng)執(zhí)行此操作的字符串函數(shù)?
如果沒有,是否可以編寫自己的函數(shù)?
Is there a string function that does this automatically?
If not, is it possible to write my own function?
推薦答案
它應(yīng)該可以正常工作,但您需要對函數(shù)進(jìn)行模式限定.
It should work fine, but you need to schema-qualify functions.
瀏覽器:
SELECT dbo.BaseSplit(line,';') FROM table
如果您的函數(shù)在與 dbo 不同的架構(gòu)中,您顯然應(yīng)該改用它.
If your function is in a different schema than dbo you should obviously use that instead.
好的 - 假設(shè)它是一個(gè)表值函數(shù)然后......
OK - assuming its a table valued function then...
SELECT t.Id, f.* FROM table AS t CROSS APPLY dbo.BaseSplit(line,';') AS f
這將為每個(gè)分割線返回一行 + 主表中該條目的 ID(假設(shè)主表中存在名為 Id 的列).如果您想要更好,我將需要一個(gè)您期望的輸出示例
That would return a row for each split line + the ID of the that entry in the main table (assuming a column named Id exists in the main table). If you want better that that I'm going to need an example of what output you expect
這篇關(guān)于有沒有“分裂"?用于 SELECT 查詢的 t-sql 中的函數(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!