Friday, November 6, 2015

SQL split a comma separated string

SQL split a comma separated string


 DECLARE @valueList varchar(8000)  
 DECLARE @pos INT  
 DECLARE @len INT  
 DECLARE @value varchar(8000)  
 DECLARE @i INT=0  
 SET @valueList = ',Atik,Khabir,Shahed,Shain,Ashek,Noman'  
 set @pos = 0  
 set @len = 0  
 WHILE CHARINDEX(',', @valueList, @pos+1)>0  
 BEGIN  
   set @len = CHARINDEX(',', @valueList, @pos+1) - @pos  
   set @value = SUBSTRING(@valueList, @pos, @len)  
      set @i=@i+1   
   --SELECT @pos, @len, @value /*this is here for debugging*/  
     IF(@i=1) -- now you can set condition  
           BEGIN  
            PRINT @value   
           END  
            IF(@i=2)  
           BEGIN  
            PRINT @value   
           END  
            IF(@i=3)  
           BEGIN  
            PRINT @value   
           END  
            IF(@i=4)  
           BEGIN  
            PRINT @value   
           END  
   set @pos = CHARINDEX(',', @valueList, @pos+@len) +1  
 END  


Ensure that this project has Microsoft.Bcl.Build installed and packages.config is located next to the project file

In my Xamarin form application their was dependency Restclient on Microsoft.Bcl.Build Microsoft.Bcl. i just remove all using nuget and ...