I am attempting to produce a 'parameterized view' in the form of a pipelined table function, where arguments to the function are used to build dynamic sql (a Select statement). The output of the Select would feed into a cursor. I would then fetch the rows of the cursor and pipe them out (after a little manipulation).
The problem that I have is that the parameters I am passing in need to be used to form the table names from which I am selecting. In other words, it's my From clause that is parameterized. All of the examples I have been able to find so far only show parameterized Where clauses.
Every method I have attempted using Table(myVar), Table(cast(myVar as SomeTableType)), etc has failed.
Can anyone share a working example of dynamic sql (preferably feeding a cursor), where the sql has a parameterized From clause?
Thank you in advance for your help!
Neil