Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 335 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I split a delimited string so I can access individual items?

#21
I use the answer of frederic but this did not work in SQL Server 2005

I modified it and I'm using `select` with `union all` and it works

DECLARE @str varchar(max)
SET @str = 'Hello John Smith how are you'

DECLARE @separator varchar(max)
SET @separator = ' '

DECLARE @Splited table(id int IDENTITY(1,1), item varchar(max))

SET @str = REPLACE(@str, @separator, ''' UNION ALL SELECT ''')
SET @str = ' SELECT ''' + @str + ''' '

INSERT INTO @Splited
EXEC(@str)

SELECT * FROM @Splited

And the result-set is:

id item
1 Hello
2 John
3 Smith
4 how
5 are
6 you
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through