我正在使用一个返回数据集的存储过程。我的程序是这样的
ALTER procedure [dbo].[USP_DisplaySaldetails]
as begin
DECLARE @cols AS NVARCHAR(MAX),
@query AS NVARCHAR(MAX)
select @cols = STUFF((SELECT ',' + QUOTENAME(SST_Name)
from CM_SalType where SST_isdeleted='false'
group by SST_id, SST_Name
order by SST_id
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
set @query = 'SELECT U_id, ' + @cols + '
from
(
select t.SST_Name,
s.U_id,u.U_Fname,u.U_lname,
s.SSV_Value
from CM_SalType t
left join CM_StaffSal s
on t.SST_id = s.SST_id inner join CM_User u on u.U_id=s.U_id
) x
pivot
( max(SSV_Value)
for SST_Name in (' + @cols + ')
) p '
execute(@query)
end
结果集是
| U_ID | BASIC | HRA | DA |
------------------------------
| 11 | 15000 | 0.1 | 0.75 |
| 12 | 10000 | 0.01 | 0.5 |
这里列名是dynamic.so如何从mvc3调用此过程以及如何将数据集导入我的控制器。没有参数传递给存储过程
我的表格结构的详细信息位于Assign value of a column in a table as columname of another table。我正在使用实体框架