123常用存储过程集锦.doc
上传人:qw****27 上传时间:2024-09-12 格式:DOC 页数:6 大小:40KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

123常用存储过程集锦.doc

123常用存储过程集锦.doc

预览

在线预览结束,喜欢就下载吧,查找使用更方便

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

常用存储过程集锦,都是一些mssql常用的一些,大家可以根据需要选择使用。=================分页==========================/*分页查找数据*/CREATEPROCEDURE[dbo].[GetRecordSet]@strSqlvarchar(8000),--查询sql,如select*from[user]@PageIndexHYPERLINK"http://whatis.ctocio.com.cn/searchwhatis/69/6025569.shtml"\t"_bank"int,--查询当页号@PageSizeint--每页显示记录ASHYPERLINK"http://whatis.ctocio.com.cn/searchwhatis/23/5949023.shtml"\t"_bank"setnocountondeclare@p1intdeclare@currentPageintset@currentPage=0declare@RowCountintset@RowCount=0declare@PageCountintset@PageCount=0execsp_cursoropen@p1output,@strSql,@scrollopt=1,@ccopt=1,@rowcount=@rowCountoutput--得到总记录数select@PageCount=ceiling(1.0*@rowCount/@pagesize)--得到总页数,@currentPage=(@PageIndex-1)*@PageSize+1select@RowCount,@PageCountexecsp_cursorfetch@p1,16,@currentPage,@PageSizeexecsp_cursorclose@p1setnocountoffGO=========================用户注册============================/*用户注册,也算是添加吧*/Createproc[dbo].[UserAdd](@loginIDnvarchar(50),--登录帐号@HYPERLINK"http://whatis.ctocio.com.cn/searchwhatis/435/6025935.shtml"\t"_bank"passwordnvarchar(50),--密码@emailnvarchar(200)--电子信箱)asdeclare@userIDint--用户编号--登录账号已经被注册ifexists(selectloginIDfromtableNamewhereloginID=@loginID)beginreturn-1;end--邮箱已经被注册elseifexists(selectemailfromtableNamewhereemail=@email)beginreturn-2;end--注册成功elsebeginselect@userID=isnull(max(userID),100000)+1fromtableNameinsertintotableName(userID,loginID,[password],userName,linkNum,HYPERLINK"http://whatis.ctocio.com.cn/searchwhatis/255/6025255.shtml"\t"_bank"address,email,createTime,status)values(@userID,@loginID,@password,'','','',@email,getdate(),1)return@userIDend==========================sqlHYPERLINK"http://whatis.ctocio.com.cn/searchwhatis/497/5948997.shtml"\t"_bank"server系统存储过程===================–1.给表中字段添加描述信息CreateHYPERLINK"http://whatis.ctocio.com.cn/searchwhatis/456/6028456.shtml"\t"_bank"tableT2(idHYPERLINK"http://whatis.ctocio.com.cn/searchwhatis/69/6025569.shtml"\t"_bank"int,namechar(20))GOEXECsp_addextendedproperty'MS_Description','EmployeeID','user',dbo,