Skip to content
Advertisement

How to use scalar variable in XML Path query SQL?

I want to pass table name into into a scalar variable @Table_Name as a string. But I am getting error as:

Must declare the table variable @Table_Name.

How to achieve the same? Below is my code snippet:

Advertisement

Answer

So I created a temporary table using the input provided by the user and used that temp table in the query. Following is a code snippet:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement