Create View - Declare a variable

前端 未结 3 1560
灰色年华
灰色年华 2021-01-04 05:17

I am creating a view that is using that STUFF function. I want to put the result of STUFF in a variable for my view. The problem I am having is dec

3条回答
  •  鱼传尺愫
    2021-01-04 05:44

    You can't declare variables in a view. Could you make it into a function or stored procedure?

    Edit - you might also be able to put something into a CTE and keep it as a view.

    e.g.

    with conditions as 
    (
     ... do the STUFF here
    )
    select blah
    from blah
    inner join conditions
    (or cross join conditions if its just one row, I can't quite decipher what your data is like)
    

提交回复
热议问题