欢迎莅临 SUN WU GANG 的园子!!!

世上无难事,只畏有心人。有心之人,即立志之坚午也,志坚则不畏事之不成。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

一.使用临时表方式处理

EXEC [dbo].[ProcTotalScoreCountStatistics] '报告质量','2021-08-08 10:32:00','2024-12-30 10:32:00','999002002' 
------------------------------查询存储过程数据步骤------------------------------
--1.创建临时表
create table #temp
(
type nvarchar(50), 
five nvarchar(50), 
four nvarchar(50), 
three nvarchar(50), 
two nvarchar(50), 
one nvarchar(50), 
totalcount nvarchar(50), 
qualitybatch nvarchar(50)
)
--2.将存储结果存入临时表
insert into #temp EXEC [dbo].[ProcTotalScoreCountStatistics] '报告质量','2021-08-08 10:32:00','2024-12-30 10:32:00','999002002' 
--3.查询临时表数据,即存储结果数据
select * from #temp where qualitybatch =1
--4.清除临时表
drop table #temp

 二.使用表变量处理方式(执行结果如上图所示)

EXEC [dbo].[ProcTotalScoreCountStatistics] '报告质量','2021-08-08 10:32:00','2024-12-30 10:32:00','999002002' 
--1. 申明表变量
 declare @tempTable Table
 (
	type nvarchar(50), 
	five nvarchar(50), 
	four nvarchar(50), 
	three nvarchar(50), 
	two nvarchar(50), 
	one nvarchar(50), 
	totalcount nvarchar(50), 
	qualitybatch nvarchar(50)
 )
 
 --2. 执行存储过程并将存储过程的返回结果集插入表中
 insert into @tempTable EXEC [dbo].[ProcTotalScoreCountStatistics] '报告质量','2021-08-08 10:32:00','2024-12-30 10:32:00','999002002' 
 
 --3. 检索、查询
 select * from @tempTable where qualitybatch =1

  

posted on 2024-01-17 17:52  sunwugang  阅读(3)  评论(0编辑  收藏  举报