Search
 
SCRIPT & CODE EXAMPLE
 

SQL

TSQL function split string

CREATE FUNCTION FUNC_Split](@text VARCHAR(8000), @delimiter VARCHAR(20) = ' ')
RETURNS @Strings TABLE
(   
  position INT IDENTITY PRIMARY KEY,
  value VARCHAR(8000)  
)
AS
BEGIN
DECLARE @index INT
SET @index = -1

WHILE (LEN(@text) > 0)
  BEGIN 
    SET @index = CHARINDEX(@delimiter , @text) 
    IF (@index = 0) AND (LEN(@text) > 0) 
      BEGIN  
        INSERT INTO @Strings VALUES (@text)
          BREAK 
      END 
    IF (@index > 1) 
      BEGIN  
        INSERT INTO @Strings VALUES (LEFT(@text, @index - 1))  
        SET @text = RIGHT(@text, (LEN(@text) - @index)) 
      END 
    ELSE
      SET @text = RIGHT(@text, (LEN(@text) - @index))
    END
  RETURN
END
Comment

PREVIOUS NEXT
Code Example
Sql :: checking data type in sql server 
Sql :: get locked tables sql server 
Sql :: oracle create table as select 
Sql :: if null put 0 sql 
Sql :: truncate psql 
Sql :: osm2pgsql mac 
Sql :: select case when oracle 
Sql :: Which MySQL data type to use for storing boolean values 
Sql :: postgres create multiple index 
Sql :: SQL print multiple variable 
Sql :: how to define a save method in ruby for sqlite3 databases 
Sql :: insert query mysql workbench 
Sql :: mysql best tutorial for beginners 
Sql :: import mysql database command line 
Sql :: sql datum formatieren 
Sql :: sql insert values into table 
Sql :: mysql remove database 
Sql :: sql where not like in list 
Sql :: top 3 salary in sql 
Sql :: oracle alter table add column 
Sql :: mariadb create view 
Sql :: mysql default port number 
Sql :: sql default constraint 
Sql :: oracle drop type 
Sql :: sql as 
Sql :: insert data from one database table to another database table in postgresql using pgadmin 
Sql :: convert minutes to hours sql 
Sql :: hibernate show sql xml property 
Sql :: get number of rows in every table mysql 
Sql :: oracle uptime 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =