存储过程
来源:互联网 发布:p2p网络理财排名 编辑:程序博客网 时间:2024/05/17 03:08
1、 存储过程的创建:
create proc 存储过程的名字 as select * from 建立存储过程的表名; go
查询存储过程:exec加存储过程名
2、 创建带输入参数的存储过程:
create proc存储过程的名字
@name varchar(20) As select * from建立存储过程的表名where Name=@name go
查询存储过程:exec加存储过程名 需要查询的姓名
3、 创建带2个输入参数的存储过程:
create proc存储过程的名字 @name varchar(20), @age int As select * from建立存储过程的表名where Name=@name or Age=@age go
查询存储过程:exec加存储过程名 需要查询的姓名,查询的年龄
4、 带输出参数的存储过程(例如输出年龄):
create proc存储过程的名字 @name varchar(20),@age int output As select @age=age from 建立存储过程的表名 where Name=@name go
执行的命令:begin
declare @age varchar(20)
exec proUserInfo3 '李哲',@age output
select @age
end
查询出叫“李哲”的年龄
5、 表的数据的分页:
select * from
(select ROW_NUMBER() over(order by 分页依据的属性)
as rownum,
* from 需要分页的表) t
where
t.rownum>3 and t.rownum<=6——排出的是大于3小于等于6的数据
6、存储过程分页:
create proc 存储过程的名字
@pagesize int,
@pageindex int
as
select * from (select ROW_NUMBER() over(order by排序分页的属性)as
rownum,* from需要分页的表)t where
rownum>(@pageindex-1)*@pagesize
and
rownum<=@pageindex*@pagesize
go
调用:
Exec 排序分页的属性 没页的行数,第几页
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程
- 存储过程的使用
- 4234
- CComboBox 下拉列表删除最后一个选项时,不为空,必须要调用SetCurSel(-1)才可以清空。
- ubuntu linux 下 adb 连接andoid 设备失败的处理以及刷机
- HDU---1114题Piggy-Bank
- 存储过程
- 二十年后的回眸(5)——一部单车闯天下
- 常用的c_c++代码
- CFileFind类
- 让970的ADB运行在root权限下的方法
- centos 6.2用yum安装中文输入法
- 学习是一个过程
- 2.24
- 12.01.08 ~ 12.02.25