VARCHAR(MAX) acting weird when concatenating string

前端 未结 1 1863
走了就别回头了
走了就别回头了 2021-01-18 03:37

I have a concatenating query:

DECLARE @path NVARCHAR(max) 
SELECT @path = ISNULL(@path + \'/\', \'\') + url_segment 
    FROM navigation_self_and_parents(281         


        
相关标签:
1条回答
  • 2021-01-18 04:05

    This approach to string concatenation does usually work but it isn't guaranteed.

    The official line in the KB article for a similar issue is that "The correct behavior for an aggregate concatenation query is undefined."

    There must be some subtle difference between the plans. You can either tweak the query to remove the difference and get the required execution plan or you could/should of course just use XML PATH as you are on SQL Server 2005 and this is documented to work.

    0 讨论(0)
提交回复
热议问题