如何在sqlserver中使用Split函数 [英] How to use Split function in sqlserver

查看:78
本文介绍了如何在sqlserver中使用Split函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我有一张像ShownBelow的桌子...



Hi Friends,

I have one Table like ShownBelow...

Domain Name	Min Years	MaxYears
.com                2               10
.net                4               12
.co                 1               12
.buz                1               13





但是将参数传递给存储过程就像这样.com,.net,.co

现在我需要拆分这个值并检查数据库,然后再次需要返回上表中的数据集





But Am passing parameter to stored procedure like this way .com,.net,.co
Now i need to split this value and check with database and again i need to return dataset like above table

Domain Name	Min Years	MaxYears
.com                2               10
.net                4               12
.co                 1               13
.buz                1               13

推荐答案

AFAIK,SQL Server没有拆分功能。



但是像这个 [ ^ ]可能对您有所帮助。
AFAIK, there is no split function is SQL Server.

However something like this[^] might help you.


您好,



另请参见:



Hi,

See this also:

declare @str varchar(100)
set @str = "val1_val2,val3_val4"


declare @str varchar(100) = 'val1_val2,val3_val4'

select substring(f.value, 0, charindex('_', f.value)) as val1
      ,substring(f.value, charindex('_', f.value) + 1, LEN(f.value) ) as val2
from dbo.fnSplitString(@str, ',') f





也可以查看此链接。

SQL Server中的数组和列表



谢谢



Checkout this link too.
Arrays and Lists in SQL Server

Thanks


这篇关于如何在sqlserver中使用Split函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆