Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7667093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:00:41+00:00 2026-05-31T15:00:41+00:00

I realize this question has been asked before, but I can’t get it to

  • 0

I realize this question has been asked before, but I can’t get it to work for some reason.

I’m using the split function from this SQL Team thread (second post) and the following queries.

--This query converts the interests field from text to varchar
select
    cp.id
    ,cast(cp.interests as varchar(100)) as interests
into #client_profile_temp
from
    client_profile cp

--This query is supposed to split the csv ("Golf","food") into multiple rows            
select
    cpt.id
    ,split.data
from
    #client_profile_temp cpt
    cross apply dbo.split(
    cpt.interests, ',') as split  <--Error is on this line

However I’m getting an

Incorrect syntax near '.'

error where I’ve marked above.

In the end, I want

ID              INTERESTS
000CT00002UA    "Golf","food"

to be

ID              INTERESTS
000CT00002UA    "Golf"
000CT00002UA    "food"

I’m using SQL Server 2008 and basing my answer on this StackOverflow question. I’m fairly new to SQL so any other words of wisdom would be appreciated as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:00:42+00:00Added an answer on May 31, 2026 at 3:00 pm
    from
        #client_profile_temp cpt
        cross apply dbo.split(
        #client_profile_temp.interests, ',') as split  <--Error is on this line
    

    I think the explicit naming of #client_profile_temp after you gave it an alias is a problem, try making that last line:

        cpt.interests, ',') as split  <--Error is on this line
    

    EDIT You say

    I made this change and it didn’t change anything

    Try pasting the code below (into a new SSMS window)

    create table #client_profile_temp
    (id int,
    interests varchar(500))
    
    insert into  #client_profile_temp
    values
    (5, 'Vodka,Potassium,Trigo'),
    (6, 'Mazda,Boeing,Alcoa')
    
    select
       cpt.id
      ,split.data
    from
        #client_profile_temp cpt
        cross apply dbo.split(cpt.interests, ',') as split 
    

    See if it works as you expect; I’m using sql server 2008 and that works for me to get the kind of results I think you want.

    Any chance when you say “I made the change”, you just changed a stored procedure but haven’t run it, or changed a script that creates a stored procedure, and haven’t run that, something along those lines? As I say, it seems to work for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize that this question has been asked before - but none of the
Now, I realize that this question has been answered before, but I just can't
I realize that this question has been asked 100times but none that I have
I realize this question has been asked and answered in the past, but I'm
I realize this has been asked before, but I wasn't able to find a
I realize that this question has been asked and has been answered here but
I know this question has been asked before, but none of the existing SO
I realise this question has been asked before, but after going through the previously
I realize this question is very likely to have been asked before, but I've
Perhaps this question has been asked before in a different way, but I haven’t

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.