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
Post a Comment