当前位置:网站首页>【SQL】字符串系列2:将一个字符串根据特定字符分拆成多行
【SQL】字符串系列2:将一个字符串根据特定字符分拆成多行
2022-04-23 20:32:00 【木易随风】
将一个字符串根据特定字符分拆成多行,例如:将数学,物理,历史,生物,语文,英语,化学,地理分成成8行显示。
Select * From dbo.StrToColEx('数学,物理,历史,生物,语文,英语,化学,地理',',') b
- 1.
CREATE function dbo.StrToColEx (@str Varchar(max),@separator varchar(10))
returns @T table(Col varchar(max),sort int)
as
Begin
Declare @i int
declare @index int
set @index=1
Set @i=0
Set @[email protected][email protected]
While(@i<=len(@str))
Begin
Insert @T select substring(@str,@i,charindex(@separator,@str COLLATE Chinese_PRC_CS_AS_KS_WS,@i)[email protected]) ,@index
Select @i=charindex(@separator,@str COLLATE Chinese_PRC_CS_AS_KS_WS,@i)+LEN(@separator)
set @[email protected]+1
End
return
End
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
版权声明
本文为[木易随风]所创,转载请带上原文链接,感谢
https://blog.51cto.com/muyi/5248737
边栏推荐
- Historical track data reading of Holux m1200-e Bluetooth GPS track recorder
- RT-1052学习笔记 - GPIO架构分析
- DNS cloud school rising posture! Three advanced uses of authoritative DNS
- LeetCode 994、腐烂的橘子
- go-zero框架数据库方面避坑指南
- SQL gets the latest record of the data table
- Leetcode 709, convert to lowercase
- LeetCode 1337、矩阵中战斗力最弱的 K 行
- 黑客的入侵方式你知道几种?
- Paper writing 19: the difference between conference papers and journal papers
猜你喜欢
How to protect ECs from hacker attacks?
Handwritten Google's first generation distributed computing framework MapReduce
Automatically fill in body temperature and win10 task plan
What is the difference between a host and a server?
Browser - learning notes
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
Leetcode 542, 01 matrix
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
随机推荐
【PTA】L2-011 玩转二叉树
The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
Linux64Bit下安装MySQL5.6-不能修改root密码
Leetcode 74. Search two-dimensional matrix
Es index (document name) fuzzy query method (database name fuzzy query method)
Click an EL checkbox to select all questions
Handwritten Google's first generation distributed computing framework MapReduce
Parsing methods of JSON data in C - jar and jobobject: error reading jar from jsonreader Current JsonReader item
Recognition of high-speed road signs by Matlab using alexnet
go-zero框架数据库方面避坑指南
Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
A login and exit component based on token
缓存淘汰算法初步认识(LRU和LFU)
Commit and rollback in DCL of 16 MySQL
Preliminary understanding of cache elimination algorithm (LRU and LFU)
2022dasctf APR x fat epidemic prevention challenge crypto easy_ real
Use of node template engine
Rédaction de thèses 19: différences entre les thèses de conférence et les thèses périodiques
An error is reported in the initialization metadata of the dolphin scheduler -- it turns out that there is a special symbol in the password. "$“
Analysis of the relationship between generalized Bim and CAD under the current background