CREATE PROCEDURE jsd
@js int
AS
declare @sql nvarchar(4000)
set @sql = 'select 住院序号,SUM(金额) as 合计'
select @sql = @sql + ',Sum(case 费用类别 when ''' + 费用类别 + ''' then 金额 else 0 end) as [' + 费用类别 + ']'
from (select distinct 编码,费用类别 from dbo.F费用类别) as c
set @sql = @sql + ' from
(select a.住院序号,a.金额,b.费用类别 from ST结算单 a
join F费用类别 b on a.费用类别编码= b.编码 where 住院序号 = @js) as d
group by 住院序号'
exec sp_executesql @sql,N'@js AS int',@js
return
GO
此主题相关图片如下:qq截图未命名.png
现在只知道Tables("表名").Fill("jsd 7","连接名",True)这一种。。
还有别的方式方法吗?
比如SQLGroupTableBuilder这些能引用吗?
[此贴子已经被作者于2010-1-19 0:17:50编辑过]