经典的sql存储过程 用了临时表变量

create proc UInfo(@Uid varchar(36))
as
begin
declare @ResultDt table(cname varchar(64),acount int,ccount int,scount int)
set @Uid='simao'
declare  @tempcount int
insert into @ResultDt select
'商铺 ',(select count(1) from ShopOffice where UID=@Uid),(select count(1) from ShopOffice where SCommand=1 and UID=@Uid),(select count(1) from ShopOffice where NStatus=3 and UID=@Uid)
insert into @ResultDt select
'写字楼',(select count(1) from OfficeBuilding where UID=@Uid),(select count(1) from OfficeBuilding where SCommand=1 and UID=@Uid),(select count(1) from OfficeBuilding where NStatus=3 and UID=@Uid)
insert into @ResultDt select
'工业地产',(select count(1) from Industrial where UID=@Uid),(select count(1) from Industrial where SCommand=1 and UID=@Uid),(select count(1) from Industrial where NStatus=3 and UID=@Uid)
insert into @ResultDt select
'大型项目',(select count(1) from Project where UID=@Uid),(select count(1) from Project where SCommand=1 and UID=@Uid),(select count(1) from Project where NStatus=3 and UID=@Uid)
insert into @ResultDt select
'生意转让',(select count(1) from Bussiness where UID=@Uid),(select count(1) from Bussiness where SCommand=1 and UID=@Uid),(select count(1) from Bussiness where NStatus=3 and UID=@Uid)
insert into @ResultDt select
'合计',sum(acount),sum(ccount),sum(scount) from @ResultDt
select * from @ResultDt
end <script type="text/javascript"><!-- google_ad_client = "pub-1985112462197986"; /* 新广告 336x280, 创建于 10-8-20 */ google_ad_slot = "6915893334"; google_ad_width = 336; google_ad_height = 280; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><script type="text/javascript"><!-- google_ad_client = "pub-1985112462197986"; /* 336x280, 创建于 10-6-25 */ google_ad_slot = "9255958887"; google_ad_width = 336; google_ad_height = 280; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值