Home > Database > Mysql Tutorial > 根据指定字符分割字符串并输出表格

根据指定字符分割字符串并输出表格

WBOY
Release: 2016-06-07 14:56:35
Original
1039 people have browsed it

根据指定字符分割字符串并输出表格 无 CREATE FUNCTION [dbo].[Splitstring] (@StringToSplit NVARCHAR(max), @CharSpliter NVARCHAR(5)) returns @SplitTable TABLE ( data NVARCHAR(50)) AS BEGIN DECLARE @Count INT SET @Count = 1 WHILE ( Charindex(@Ch

根据指定字符分割字符串并输出表格
CREATE FUNCTION [dbo].[Splitstring] (@StringToSplit NVARCHAR(max), 
 @CharSpliter NVARCHAR(5)) 
returns @SplitTable TABLE ( 
 data NVARCHAR(50)) 
AS 
 BEGIN 
 DECLARE @Count INT 

 SET @Count = 1 

 WHILE ( Charindex(@CharSpliter, @StringToSplit) > 0 ) 
 BEGIN 
 INSERT INTO @SplitTable
 (data) 
 SELECT Data = Ltrim(Rtrim(Substring(@StringToSplit, 1, 
 Charindex(@CharSpliter, @StringToSplit) - 1) 
 )) 

 SET @StringToSplit= Substring(@StringToSplit, Charindex(@CharSpliter, @StringToSplit
 ) 
 + 1, 
 Len(@StringToSplit)) 
 SET @Count = @Count + 1 
 END 

 INSERT INTO @SplitTable
 (data) 
 SELECT Data = Ltrim(Rtrim(@StringToSplit)) 

 RETURN 
 END 

go 
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template