sanjaydut26 (9/30/2016)
I modified the query toDeclare @query nvarchar(max)
set @query = dbo.ufn_GetHcmDesignFields(3, 31418)
Declare @query2 nvarchar(max)
EXEC sp_executesql N'@query','@query2 nvarchar(max) output',@query2 output
select @query2 as Test
I get the same error
Can you post the code for function dbo.ufn_GetHcmDesignFields, please? This process could easily be a maintenance nightmare. Let's get that out of the way.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden