“Incorrect syntax” using a table-valued function in SELECT clause of T-SQL query

前端 未结 1 1724
梦谈多话
梦谈多话 2020-12-21 13:03

I have the following table-valued function for splitting strings. This works fine, was cribbed from elsewhere on the web, and I would have thought isn\'t the cause of the pr

相关标签:
1条回答
  • 2020-12-21 13:32

    I would guess that the database is set to compatibility mode 80 or lower.

    See sp_dbcmptlevel

    This is usually the cause if it happens in a FROM clause

    You can also write it like this

    SELECT
      a.doc_id,
      a.doc_file_name,
      foo.extension 
    FROM
      ai_docs_core a
      OUTER APPLY
      (SELECT TOP 1 s AS extension
       FROM dbo.StringSplit('.', a.doc_file_name)
       ORDER BY pn DESC
      ) foo
    
    0 讨论(0)
提交回复
热议问题