I want to use my function like this
我想像这样使用我的功能
SELECT BaseSplit(line,';') FROM table
is there any way to do that ???
有没有办法做到这一点???
I try CROSS APPLY but it not what I want
我尝试CROSS APPLY,但它不是我想要的
My table has a column named line
我的表有一个名为line的列
line
______
15;2;5
NULL
10;3;6
I want to split this column to be like
我想将此列拆分为
15
2
5
Null
10
3
6
Is there a string function that does this automatically?
If not, is it possible to write my own function?
是否有自动执行此操作的字符串函数?如果没有,是否可以编写自己的功能?
1 个解决方案
#1
1
It should work fine, but you need to schema-qualify functions.
它应该工作正常,但您需要模式限定函数。
IE:
SELECT dbo.BaseSplit(line,';') FROM table
If your function is in a different schema than dbo you should obviously use that instead.
如果你的函数与dbo的模式不同,那么显然应该使用它。
OK - assuming its a table valued function then...
好的 - 假设它有一个表值函数然后......
SELECT t.Id, f.* FROM table AS t CROSS APPLY dbo.BaseSplit(line,';') AS f
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
这将为每个分割行返回一行+主表中该条目的ID(假设主表中存在名为Id的列)。如果你想要更好,我需要一个你期望输出的例子
#1
1
It should work fine, but you need to schema-qualify functions.
它应该工作正常,但您需要模式限定函数。
IE:
SELECT dbo.BaseSplit(line,';') FROM table
If your function is in a different schema than dbo you should obviously use that instead.
如果你的函数与dbo的模式不同,那么显然应该使用它。
OK - assuming its a table valued function then...
好的 - 假设它有一个表值函数然后......
SELECT t.Id, f.* FROM table AS t CROSS APPLY dbo.BaseSplit(line,';') AS f
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
这将为每个分割行返回一行+主表中该条目的ID(假设主表中存在名为Id的列)。如果你想要更好,我需要一个你期望输出的例子