Forum Discussion
Anonymous
9 years agoNot applicable
Dynamic SQL in User Defined Function for Direct Query
I received the DECLARE error message stating I can't use declare in a Direct Query. I found out in this forum that a user defined function (UDF) is necessary to make this work: https://community.powe...
Phil_Seamark
9 years agoMicrosoft Employee
Hi Anonymous
What about calling the sp_executeSQL proc and passing your dynamic query via that?
Worked for me using Direct Query