1

I have a string like so:

DECLARE @columnCamera varchar(MAX) = 'aaa,bbb,ccc'

and I am trying to split these and loop through, I am stuck on the splitting part:

SELECT * FROM STRING_SPLIT(@columnCamera, ',')

But I get this error:

Invalid object name 'STRING_SPLIT'.

What is the proper way to split a string and loop through it?

7
  • what version of sql are you using? Commented May 2, 2018 at 20:27
  • SQL Server 2014 Commented May 2, 2018 at 20:29
  • 3
    The STRING_SPLIT function only became available in SQL Server 2016, so I'm afraid you don't have that function available. Commented May 2, 2018 at 20:30
  • I get that, what is the proper way to split a string in SQL...I did some digging and it looks super hard Commented May 2, 2018 at 20:31
  • It's supposed to be hard. CSV data is anathema to good SQL practice. Commented May 2, 2018 at 21:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.