123常用存储过程集锦

123常用存储过程集锦

ID:39773464

大小:40.50 KB

页数:6页

时间:2019-07-11

123常用存储过程集锦_第1页
123常用存储过程集锦_第2页
123常用存储过程集锦_第3页
123常用存储过程集锦_第4页
123常用存储过程集锦_第5页
资源描述:

《123常用存储过程集锦》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、常用存储过程集锦,都是一些mssql常用的一些,大家可以根据需要选择使用。  =================分页==========================  /*分页查找数据*/  CREATE PROCEDURE [dbo].[GetRecordSet]  @strSql varchar(8000),--查询sql,如select * from [user]  @PageIndex int,--查询当页号  @PageSize int--每页显示记录  AS  set nocount on  declare @p1 int  declare @currentPag

2、e 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=(@PageI

3、ndex-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),     --登录帐号 

4、 @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;

5、  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=================

6、=========sqlserver系统存储过程===================  –1.给表中字段添加描述信息  Create table T2 (id int , name char (20))  GO  EXEC sp_addextendedproperty 'MS_Description', 'Employee ID', 'user', dbo, 'table', T2, 'column', id  EXEC sp_updateextendedproperty 'MS_Description', 'this is a test', 'user', dbo, 'tab

7、le', T2, 'column', id  –2.修改数据库名称  EXEC sp_renamedb 'old_db_name', 'new_db_name'  –3.修改数据表名称和字段名称  EXEC sp_rename 'old_table_name', 'new_table_name'–修改数据表名称  EXEC sp_rename 'table_name.[old_column_name]', 'new_column_name', 'COLUMN'–修改字段名称  –

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。