1

I am trying to join with table values function, it gives me error this error:

Msg 170, Level 15, State 1, Line 2 Line 2: Incorrect syntax near '.'.

SELECT * from tbl t
inner join dbo.ufn_CSVToTable(t.text) a 
on t.text = a.String

What can be the error?

7
  • what is the meaning of "(t.text)" ? Commented Jan 5, 2012 at 20:28
  • Please post the code behind the function--can't help you otherwise. Commented Jan 5, 2012 at 20:28
  • text is the column name in table tbl. Commented Jan 5, 2012 at 20:29
  • function is fine i have checked this. if i execute the function like this SELECT * from dbo.ufn_CSVToTable('1,2,3') then it works fine but when i pass the column name as parameter then it gives error. Commented Jan 5, 2012 at 20:31
  • 1
    possible duplicate of "Incorrect syntax" using a table-valued function in SELECT clause of T-SQL query Commented Jan 5, 2012 at 22:02

3 Answers 3

6
  1. You need CROSS or OUTER APPLY
  2. You need to be on SQL Server 2005+
  3. And most important, the database compatibility needs to be 90 or higher
Sign up to request clarification or add additional context in comments.

Comments

3

Try using CROSS APPLY instead of JOIN:

SELECT * from tbl t
CROSS APPLY dbo.ufn_CSVToTable(t.text) a 
WHERE t.text = a.String

2 Comments

error: Msg 170, Level 15, State 1, Line 2 Line 2: Incorrect syntax near 'APPLY'.
Need to be compat level 90 or higher too msdn.microsoft.com/en-us/library/bb510680.aspx
0

Maybe try being a bit more explicit -

SELECT * from tbl
inner join dbo.ufn_CSVToTable(tbl.text) a 
on tbl.text = a.String

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.