sql server - Searching for strings in files using sql -


i have

set @file = 'aaaa,bbbb,cccc,dddd,eeee,ffff' select substring(@file,charindex(',',@file)+1, charindex(',',@file,charindex(',',@file)+1) -charindex(',',@file)-1) my_string  

this print out

     my_string     ----------------    1|     bbbb 

how make print?

   my_string  ------------ 1|   bbbb 2|   cccc 3|   dddd 4|   eeee 

try code.,(refered turning comma separated string individual rows)

declare @file varchar(max) set @file = 'aaaa,bbbb,cccc,dddd,eeee,ffff'  ;with tmp(dataitem, data)  ( select left(@file, charindex(',',@file+',')-1),     stuff(@file, 1, charindex(',',@file+','), '') union select left(data, charindex(',',data+',')-1),     stuff(data, 1, charindex(',',data+','), '') tmp data > '') select dataitem tmp 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -