SQLServer -- 自定义无参数存储过程
来源:互联网 发布:麦迪巅峰数据 编辑:程序博客网 时间:2024/06/06 12:35
自定义储过程
use StuManageDBgoif exists(Select * from sysobjects where name='usp_ScoreQuery')drop procedure usp_ScoreQuerygocreate procedure usp_ScoreQuery --创建存储过程as --查询考试信息 select Students.StudentId,StudentName,ClassName,ScoreSum=(CSharp+SQLServerDB) from Students inner join StudentClass on Students.ClassId = StudentClass.ClassId inner join ScoreList on Students.StudentId = ScoreList.StudentId order by ScoreSum DESCgoexec usp_ScoreQuery
多张表的储存过程
use StuManageDBgoif exists(Select * from sysobjects where name='usp_ScoreQuery')drop procedure usp_ScoreQuerygocreate procedure usp_ScoreQuery --创建存储过程as --查询考试信息 select Students.StudentId,StudentName,ClassName,ScoreSum=(CSharp+SQLServerDB) from Students inner join StudentClass on Students.ClassId = StudentClass.ClassId inner join ScoreList on Students.StudentId = ScoreList.StudentId order by ScoreSum DESC --查询班级平均分 select ClassName,C#Avg=Avg(CSharp),DBAvg=Avg(SQLServerDB) from ScoreList inner join Students on Students.StudentId = ScoreList.StudentId inner join StudentClass on StudentClass.ClassId = Students.ClassId group by ClassName order by ClassNamegoexec usp_ScoreQuery
存储过程临时表
在处理数据过程中临时保存一些数据。
use StuManageDBgoif exists(Select * from sysobjects where name='usp_ScoreQuery')drop procedure usp_ScoreQuerygocreate procedure usp_ScoreQuery --创建存储过程as --查询考试信息 select Students.StudentId,StudentName,ClassName,ScoreSum=(CSharp+SQLServerDB) from Students inner join StudentClass on Students.ClassId = StudentClass.ClassId inner join ScoreList on Students.StudentId = ScoreList.StudentId order by ScoreSum DESC --使用临时表 select StudentClass.ClassId,c#Avg=Avg(CSharp),DBAvg=Avg(SQLServerDB) into #ScoreTemp from ScoreList inner join Students on Students.StudentId=ScoreList.StudentId inner join StudentClass on StudentClass.ClassId = Students.ClassId group by StudentClass.ClassId order by StudentClass.ClassId --将临时表和班级查询表关联 select ClassName,c#Avg,DBAvg from #ScoreTemp inner join StudentClass on StudentClass.ClassId=#ScoreTemp.ClassIdgoexec usp_ScoreQuery
阅读全文
0 0
- SQLServer -- 自定义无参数存储过程
- SQLServer --自定义带输入参数的存储过程
- Sqlserver存储过程lis参数
- SqlServer存储过程输出参数
- sqlserver存储过程输出参数
- SqlServer存储过程(output参数)
- 无参数调用存储过程
- sqlserver存储过程的参数传递注意事项
- SQLSERVER 存储过程传递数组参数
- sqoop export SQLSERVER 存储过程参数限制
- SqlServer存储过程(带参数)
- SqlServer参数化查询与存储过程
- SQLServer--带输出参数的存储过程
- SQLSERVER 存储过程调用存储过程,如何得到输出参数
- mysql 带有无参数的存储过程
- [FineReport]柱状图(无参数存储过程)
- 使用ODBC向SQLServer存储过程传参数的方法
- SQLSERVER存储过程如何写带参数的游标
- CSS使用心得
- Linux下的platform总线驱动
- java lambda 实现事件监听 程序
- linux常用命令
- Windows C++ 常用的时间类型和函数
- SQLServer -- 自定义无参数存储过程
- spi master spi driver spi device
- platform_driver_register()--如何match之后调用probe
- 图的广度遍历
- 距离和相似度计算总结
- 动态规划与贪心算法
- mybatis 在开启二级缓存后 和悲观锁之间的
- kobject,kset,子系统层次结构 、platform_device platform_driver
- 杂记