September 2016 - Eg Net Solution

Here in this sites web and software developer can get some essential information.

MY Favorite .Net Question For Interview

This are not tidy. Just for rough. In Sha Allah will make it tiddy soon. 1.  DateTime2 Date range 0001-01-01 through 9999-12-31  vs Date...

Users Countries


Monday, September 5, 2016

Details Of Split String in Sql :: SQL Server 2014 Version(12.0.4100.1) SQL Server 2008 Version(10.50.1617.0)

September 05, 2016 0
Details Of Split String in Sql  :: SQL Server 2014 Version(12.0.4100.1) SQL Server 2008 Version(10.50.1617.0)

STRING_SPLIT (Transact-SQL) is avail able from SQL Server 2016 

As there is no built in split string function in sql server 2014, 2010, 2008 I have build the bellow function from getting help from stackloverflow.com

1. This is single paged query to under standing split string.

  1. Declare @products varchar(200) = '1,2,3,4,5,6,7,8,9,10'
  2. -- SET @products = SUBSTRING(@products, LEN('ss' + ',') + 1, LEN(@products))
  3. --select @products
  4. Declare @individual varchar(20) = null
  5. WHILE LEN(@products) > 0
  6. BEGIN
  7. IF PATINDEX('%,%',@products) > 0
  8. BEGIN
  9. SET @individual = SUBSTRING(@products, 0, PATINDEX('%,%',@products))
  10. SELECT @individual
  11. SET @products = SUBSTRING(@products, LEN(@individual + ',') + 1,
  12. LEN(@products)-1)
  13. END
  14. ELSE
  15. BEGIN
  16. SET @individual = @products
  17. SET @products = NULL
  18. SELECT @individual
  19. END
  20. END
  21. select @products

Add Choice