Search
 
SCRIPT & CODE EXAMPLE
 

SQL

String split in sql server

SELECT [Value] FROM STRING_SPLIT('Lorem ipsum dolor sit amet.', ' ');
Comment

sql Split string function

CREATE FUNCTION [dbo].[Func_SplitString] 
( @Values VARCHAR(MAX)
, @splitStr VARCHAR(50)
)

RETURNS @Result_Table TABLE
       (
	     [value] nvarchar(MAX) NULL
       )
BEGIN
    DECLARE @TempStr nvarchar(MAX)
    WHILE (CHARINDEX(@splitStr,@Values)>0)
    BEGIN
        SET @TempStr=SUBSTRING(@Values,1,CHARINDEX(@splitStr,@Values)-1)
        INSERT INTO @Result_Table (value) VALUES (ltrim(rtrim(isnull(@TempStr, ''))))
        SET @Values = REPLACE(@Values,@TempStr+@splitStr,'')
    END/*End While*/
	
    IF(LEN(RTRIM(LTRIM(@Values)))>0 AND CHARINDEX(@splitStr,RTRIM(LTRIM(@Values)))=0) 
    BEGIN
        SET @TempStr=@Values 
        INSERT INTO @Result_Table (value) VALUES (ltrim(rtrim(isnull(@TempStr, ''))))
    End /*End IF*/
   RETURN 
END
Comment

PREVIOUS NEXT
Code Example
Sql :: get latest record in sql 
Sql :: varchar plsql 
Sql :: having vs where sql 
Sql :: mysql number format 
Sql :: create column sql 
Sql :: oracle new column 
Sql :: host is not allowed to connect to this mysql server 
Sql :: postgresql array last element 
Sql :: Syntax of for-loop in SQL Server 
Sql :: sql empty table 
Sql :: update row in mysql 
Sql :: oracle asynchronous query 
Sql :: postgresql change value in column 
Sql :: mysql how to subtract dates 
Sql :: mysql convert column to uppercase 
Sql :: mysql last year 
Sql :: sql like query 
Sql :: mysql error incompatible with sql_mode=only_full_group_by 
Sql :: date_trunc postgres 
Sql :: sql not contains 
Sql :: Select last row from SQL Table 
Sql :: grant all privileges mysql 
Sql :: how to get data between a last week in mysql 
Sql :: postgres group by 10 minute intervals 
Sql :: sql server pagination limit 
Sql :: restore postgres database from dump 
Sql :: sql server query all database objects 
Sql :: mysql CAST(amount as float) 
Sql :: change role postgres 
Sql :: create user sql server 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =