我有一个带动态列的存储过程。当我更新实体框架中的存储过程时,我收到错误
存储过程不返回任何列
我在谷歌搜索过,我在我的存储过程中添加了SET FMTONLY OFF
,但我仍然没有在实体框架中获取这些列。
我的查询是这样的:
DECLARE @cols VARCHAR(MAX)
;WITH CTE AS (
SELECT ROW_NUMBER() OVER(PARTITION BY #ResourceUtilization.[DAY]
ORDER BY #ResourceUtilization.[DAY]) AS rowNbr,
#ResourceUtilization.[DAY]
FROM #ResourceUtilization )
SELECT @cols=STUFF ( ( SELECT ',' +QUOTENAME([DAY])
FROM CTE
WHERE CTE.rowNbr=1 FOR XML PATH('') ) ,1,1,'')
DECLARE @query NVARCHAR(4000)=
N'SELECT
DEPT_NAME,
EMP_NAME,
DESIGNATION,' + @cols +'
FROM
(
SELECT
RU.DEPT_NAME,
RU.EMP_NAME,
RU.DESIGNATION,
RU.[DAY],
(
CAST(RU.FIRST_SHIFT AS VARCHAR(10))+'',''+
CAST(RU.SECOND_SHIFT AS VARCHAR(10))+'',''+
CAST(RU.THIRD_SHIFT AS VARCHAR(10))+'',''+
CAST(RU.GENERAL_SHIFT AS VARCHAR(10))
) AS SHIFT
FROM
#ResourceUtilization RU
) AS p
PIVOT
(
MAX(SHIFT) FOR [DAY] IN('+@cols+')
) AS pvt'
EXECUTE(@query)
请任何人帮助我。