Search
 
SCRIPT & CODE EXAMPLE
 

SQL

TSQL convert csv to table

CREATE FUNCTION [dbo].[CSV2TABLE] (@InStr nvarchar(MAX))
RETURNS @TempTab TABLE
   (id nvarchar(MAX) NOT NULL)
AS
BEGIN
    
	SET @InStr = REPLACE(@InStr + ',', ',,', ',')
	DECLARE @SP INT
	DECLARE @VALUE nvarchar(MAX)

	WHILE PATINDEX('%,%', @INSTR ) <> 0 
	BEGIN
  	 SELECT  @SP = PATINDEX('%,%',@INSTR)
  	 SELECT  @VALUE = LEFT(@INSTR , @SP - 1)
  	 SELECT  @INSTR = STUFF(@INSTR, 1, @SP, '')
   	INSERT INTO @TempTab(id) VALUES (@VALUE)
END
	RETURN
END
Comment

PREVIOUS NEXT
Code Example
Sql :: stored procedure 
Sql :: join sql 
Sql :: on update cascade 
Sql :: select * from 
Sql :: update view sql 
Sql :: sql like operator 
Sql :: online sql compiler 
Sql :: mysql split explode 
Sql :: how to define a non primary composite key in sql 
Sql :: sql query interview questions 
Sql :: subquery sql 
Sql :: sql to linq converter 
Sql :: 18446744073709551615 mariadb left join order by 
Sql :: mariadb errno 121 
Sql :: mysql case sensitive ? 
Sql :: tipos da linguagem SQL 
Sql :: mysql and or 
Sql :: trncate table with relationships 
Sql :: search starting with mysql 
Sql :: change mysql paasword in cmd 
Sql :: ms sql bacup table 
Sql :: express api ith mysql data 
Sql :: dependency 
Sql :: how to find shortest and longest name in sql 
Sql :: what alter does in db 
Sql :: time mysql w3 
Sql :: error infor in sql server 
Sql :: what is constraints in dbms 
Sql :: combine islands dates sql 
Sql :: proc sql not in working 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =