SQL Query to Split string by specific seperator


On May 19

SQL Query to Split string by specific seperator


sql qUERY TO SPLIT STRING BY SPECIFIC SEPERATOR


DECLARE @start INT, @end INT ,@string varchar(200),@delimiter varchar(10)


set @string='DIMAPUR,KIPHIRE,KOHIMA,LONGLENG ,MOKOKCHUNG,MON,PEREN,PHEK,TUENSANG,WOKHA,ZUNHEBOTO'


    set @delimiter=','


    SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) 


    WHILE @start < LEN(@string) + 1

    BEGIN 
        IF @end = 0  
            SET @end = LEN(@string) + 1
           --print  SUBSTRING(@string, @start, @end - @start)


           update [tbl_city] set state_id=21 where city_name=SUBSTRING(@string, @start, @end - @start)


           INSERT INTO tbl_city ([state_id],[city_name]) VALUES (26,SUBSTRING(@string, @start, @end - @start))
        
          --INSERT INTO @output (splitdata)  
         --VALUES(SUBSTRING(@string, @start, @end - @start)) 
        SET @start = @end + 1 
        SET @end = CHARINDEX(@delimiter, @string, @start)

  end

You may also like :

Basic steps to implement ASP dotnet MVC using Entity Framework Code First approach
SQL Query to Release lock on database
How to change URL withought page postback
Csharp Code to make call By connecting you phone to PC
BE Electronics ETC IT Computer Project Titles - Group 1
SQL Query to Split string by specific seperator
Simple Page Method in asp.net
Error 720 Resolution
Queries in LINQ to DataSet
BEWARE-XSS THIEVES ARE LOOKING FOR YOU
how to search date within range in c Sharp dot net and mssql

You may also like :





Responses