存储过程 转化 成视图
declare @sql varchar(4000)set @sql = 'select ProjectID'
select @sql = @sql + ',max(case PropertyID when '''+PropertyID+''' then Value end) ['+PropertyID+']'
from (select distinct PropertyID from ProjectProperty) as a
select @sql = @sql+' from ProjectProperty group by ProjectID'
exec(@sql)
我现在想把这个功能转换成视图 如下:
if exists(Select Name From SySObjects Where Name = 'V_TEST' And Xtype ='V')
Drop View V_TEST
declare @sql varchar(4000)
set @sql = ' create view V_TEST as select ProjectID'
select @sql = @sql + ',max(case PropertyID when '''+PropertyID+''' then Value end) ['+PropertyID+']'
from (select distinct PropertyID from ProjectProperty) as a
select @sql = @sql+' from ProjectProperty group by ProjectID'
exec(@sql)
select * From V_TEST
提示关键字 as 附近有语法错误,V_TEST无效
哪位高人帮忙解决,或可以将上面的存储过程用其他方法写
--------------------编程问答-------------------- 帮UP
补充:.NET技术 , ASP.NET