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

SQL order by string split length

SELECT LEN(@String) - LEN(REPLACE(@String, ',', '')) + 1 
Comment

PREVIOUS NEXT
Code Example
Sql :: SQL Copy to Another Database 
Sql :: postgres data location 
Sql :: create table from existing table in sql 
Sql :: how to print sql query 
Sql :: postgresql conectar 
Sql :: how to create a table structure from another table in mysql 
Sql :: oracle parameter 
Sql :: sql primary key syntax 
Sql :: coalesce sql 
Sql :: How to import CSV file into a MySQL table 
Sql :: sql select non unique 
Sql :: timestamp difference sql 
Sql :: pl sql create table from another table 
Sql :: truncate table in sql 
Sql :: sqlite alter table add multiple column 
Sql :: oracle select json_table example 
Sql :: how to define a save method in ruby for sql databases 
Sql :: oracle show error line number 
Sql :: mysqli inner join (php) 
Sql :: truckat table mysql 
Sql :: how to delete database in mysql 
Sql :: bigquery timestamp 
Sql :: sql vs nosql or mysql vs mongodb 
Sql :: flask connect to mysql 
Sql :: graphql 
Sql :: sqlite modify row 
Sql :: sql and 
Sql :: sql get month 
Sql :: select only distinct values from another table 
Sql :: missing left parenthesis error in sql 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =