关于存储过程!求大神救急!!
有这么几张表
ModelNameInfo表(ModelID,ModelName)
ModelInfo表(ID,ModelID,ModelFieldID)
ModelFieldInfo表(ModelFieldID,ModelFieldName)
FieldInfo表(FieldID,ModelFieldID,FieldContext,ModelID)
根据ModelID查找ModelFieldID 把每一个不同ModelFieldID的值所对应的不同的FieldContex值 存到相应的ModelFieldID对应的ModelFieldName 的列中
要用存储过程实现
有哪位大大会?救急啊!!
[解决办法]
最后返回的表能是
[项目](ModelFieldName) [金额](ModelFieldName) [时间](ModelFieldName)
一月(FieldContext) 200(FieldContext) 2012年(FieldContext)这样么
if object_id('Tempdb..#temp') is not null drop table #temp
create table #temp(
id int identity(1,1) not null,
col1 nvarchar(100) null,
......--自己定义吧
)
--查询结果,插入临时表:
Insert Into #temp(col1,col2,col3...) select 你的字段1,字段2 ,字段3 ... from 你的汇总表
where ....