Wednesday 13 January 2016

how to split string return first part and second part separately in sql server


// -- Declare variables
declare @Col1 varchar(10)='2\100'

// -- Left part
select left(@Col1,len(SUBSTRING(@Col1,0,CHARINDEX('\',@Col1))))

// -- Result 1- 2

// -- Right part
 select right(@Col1,len(SUBSTRING(@Col1,CHARINDEX('\',@Col1)+1,LEN(@Col1))))


// -- Result 2- 100

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...