I am getting the error below when I use this syntax. I want to be able to pass the argument to the nodes function:-
CROSS APPLY XML_TPYE_COLUMN.nodes(@p_Xpath) AS Tab(Col)
Error:
The argument 1 of the XML data type method "nodes" must be a string literal.
Can someone tell me how do i do this correctly?
You’ll have to do this via dynamic sql since the parameter for nodes must be a string literal. This is similar to what you do when you do
sp_executesql.In other words, you need to construct your entire sql statement as nvarchar(max) and pass it to sp_executesql: