DECLARE @CSVString varchar(2000)DECLARE @Delimiter varchar(1)SELECT@CSVString = 'This,is,a,test,for,splitting,using,a,CTE,to,break,a,varchar,into,records,based,on,a,delimiter',@Delimiter = ','SET @CSVString = @CSVString+@Delimiter --- append the delimiter;WITH Res(s, r)AS(SELECTSUBSTRING(@CSVString,1, CHARINDEX(@Delimiter, @CSVString)-1) s,SUBSTRING(@CSVString,CHARINDEX(@Delimiter, @CSVString)+1, len(@CSVString)) rUNION ALLSELECTSUBSTRING(r,1, CHARINDEX(@Delimiter, r)-1) s,SUBSTRING(r,CHARINDEX(@Delimiter, r)+1, len(r)) rFROM ResWHERECHARINDEX(@Delimiter, r) > 0)SELECT s FROM Res
Ads 720 x 90
Home
› Uncategorized
Related Posts
There is no other posts in this category.Total Pageviews
Label List
- Architecture
- Art of SQL Server
- asynchronous mirroring
- csv
- dmv
- find outdated Statistics
- Free SQL Server tools
- index fragmentation
- Installation
- Katmai
- Learn SQL Server 2005
- Maintenance Plan
- outdated Statistics
- Reset Identity column
- Scripts
- SPID
- sql server 2008
- sys.dm_db_index_physical_stats
- sys.dm_exec_connections
- tsql
- update statistics