----------------SQL常用存储过程(一)--------------------
来源:互联网 发布:php中echo可以有逗号吗 编辑:程序博客网 时间:2024/06/11 00:08
常用存储过程集锦,都是一些mssql常用的一些,大家可以根据需要选择使用。
=================分页==========================
/*分页查找数据*/
CREATE PROCEDURE [dbo].[GetRecordSet]
@strSql varchar(8000),--查询sql,如select * from [user]
@PageIndex int,--查询当页号
@PageSize int--每页显示记录
AS
set nocount on
declare @p1 int
declare @currentPage int
set @currentPage = 0
declare @RowCount int
set @RowCount = 0
declare @PageCount int
set @PageCount = 0
exec sp_cursoropen @p1 output,@strSql,@scrollopt=1,@ccopt=1,@rowcount=@rowCount output --得到总记录数
select @PageCount=ceiling(1.0*@rowCount/@pagesize) --得到总页数
,@currentPage=(@PageIndex-1)*@PageSize+1
select @RowCount,@PageCount
exec sp_cursorfetch @p1,16,@currentPage,@PageSize
exec sp_cursorclose @p1
set nocount off
GO
=========================用户注册============================
/*
用户注册,也算是添加吧
*/
Create proc [dbo].[UserAdd]
(
@loginID nvarchar(50), --登录帐号
@password nvarchar(50), --密码
@email nvarchar(200) --电子信箱
)
as
declare @userID int --用户编号
--登录账号已经被注册
if exists(select loginID from tableName where loginID = @loginID)
begin
return -1;
end
--邮箱已经被注册
else if exists(select email from tableName where email = @email)
begin
return -2;
end
--注册成功
else
begin
select @userID = isnull(max(userID),100000)+1 from tableName
insert into tableName
(userID,loginID,[password],userName,linkNum,address,email,createTime,status)
values
(@userID,@loginID,@password,'','','',@email,getdate(),1)
return @userID
end
- ----------------SQL常用存储过程(一)--------------------
- SQL 常用存储过程
- 常用sql存储过程集锦
- 常用sql存储过程集锦
- SQL 常用系统存储过程
- -----------------------SQL常用存储过程(二)---------------------
- 常用的sql语句及存储过程
- 常用的SQL语句及存储过程
- MS Sql 存储过程 事务 常用代码
- ASP.Net中常用SQL存储过程
- SQL Server常用系统存储过程
- SQL存储过程一些常用方法
- 常用sql自定义函数以及存储过程
- 收集的SQL常用存储过程
- Sql Server 常用系统存储过程
- SQL SERVER常用系统存储过程
- Sql Server 2008 常用系统存储过程
- Sql Server 常用系统存储过程大全
- [HOW TO]如何在iPhone应用程序中发送邮件
- tcp/ip 学习笔记
- 物化视图,索引,数据仓库
- 看电影
- asus_华硕P535专用UCWEB 7.0版 CAB安装包下载
- ----------------SQL常用存储过程(一)--------------------
- C文件操作
- C#开源资源大汇总
- 题目:org.springframework.beans.factory.BeanCreationException(hibernate中的jar包和spring中的jar包冲突)异常产生的原因和解决方案。
- -----------------------SQL常用存储过程(二)---------------------
- Exadata 机器介绍
- ===================阿拉伯数字转大写中文=============
- poj1083
- 虚拟机上Redhat linux9.0的VMware Tools详细图文教程