当前位置: 首页 > news >正文

给你一个网站怎么做个人信息管理网站建设

给你一个网站怎么做,个人信息管理网站建设,网站域名续费一年多少钱,做销售怎么和客户聊天sql编程2 游标与存储过程 sql编程中的游标的使用#xff1a;提供的一种对查询的结果集进行逐行处理的一种方式不用游标的处理解决方式#xff1a;逐行修改工资update salar set 工资‘新工资’ where 雇员号0101 //通过查出雇员号而修改工资过程#xff1a;1.定义一个游标提供的一种对查询的结果集进行逐行处理的一种方式不用游标的处理解决方式逐行修改工资update salar set 工资‘新工资’ where 雇员号0101 //通过查出雇员号而修改工资过程1.定义一个游标只想某个结果集的一个行指针 cursor 游标类型例 declare ll_cursor cursor for select * from students2.打开游标 open ll_cursor3.依次往下读取结果集中的每一行数据/****** Script for SelectTopNRows command from SSMS ******/SELECT TOP 1000 [id] ,[son] ,[name] ,[sex] ,[age] FROM [SchoolIDB].[dbo].[students] declare id int declare son nvarchar declare name nvarchar declare sex nvarchar declare age int declare ll_cursor cursor for select * from students open ll_cursor fetch next from ll_cursor into id,son,name,sex,age print id print son print name print sex print age close ll_cursor //关闭游标 deallocate ll_cursor //释放资源 //注意Cursorfetch: INTO 列表中声明的变量数目必须与所选列的数目相同。必须与列名的数量相同 //id,name..等 游标的原理通过在结果集中设立的一个指针来从上往下一行行遍历数据的一个过程 注意//在遍历完成后需要关闭游标 并且释放掉资源 2.可以通过访问fetch_status 全局变量的值来判断当前是否读取到数据航如果fetch_studet0 说明读取成功否则就是读取失败 存储过程预先编译好一段sql语句用来实现特定得功能类似c#中的方法定义存储过程的语法gocreate procedure usp_过程名as sql语句....存储过程的命名规范usp_功能例定义一个课程名变量name nvarchar(25)as select idid from course where namename //通过name 名来找到id 调用存储过程execute 存储过程名存储过程也分有参和无参--调用、执行存储过程exec proc_get_student; //在不同的地方调而不是在本程序调用 3、 修改存储过程 --修改存储过程alter proc proc_get_studentasselect * from student; 4、 带参存储过程 --带参存储过程if (object_id(proc_find_stu, P) is not null) drop proc proc_find_stugocreate proc proc_find_stu(startId int, endId int)as select * from student where id between startId and endIdgo exec proc_find_stu 2, 4; 5、 带通配符参数存储过程 --带通配符参数存储过程if (object_id(proc_findStudentByName, P) is not null) drop proc proc_findStudentByNamegocreate proc proc_findStudentByName(name varchar(20) %j%, nextName varchar(20) %)as select * from student where name like name and name like nextName;go exec proc_findStudentByName;exec proc_findStudentByName %o%, t%; 6、 带输出参数存储过程 if (object_id(proc_getStudentRecord, P) is not null) drop proc proc_getStudentRecordgocreate proc proc_getStudentRecord( id int, --默认输入参数 name varchar(20) out, --输出参数 age varchar(20) output--输入输出参数)as select name name, age age from student where id id and sex age;go -- declare id int, name varchar(20), temp varchar(20);set id 7; set temp 1;exec proc_getStudentRecord id, name out, temp output;select name, temp;print name # temp; 7、 不缓存存储过程 --WITH RECOMPILE 不缓存if (object_id(proc_temp, P) is not null) drop proc proc_tempgocreate proc proc_tempwith recompileas select * from student;go exec proc_temp; 8、 加密存储过程 --加密WITH ENCRYPTION if (object_id(proc_temp_encryption, P) is not null) drop proc proc_temp_encryptiongocreate proc proc_temp_encryptionwith encryptionas select * from student;go exec proc_temp_encryption;exec sp_helptext proc_temp;exec sp_helptext proc_temp_encryption; 9、 带游标参数存储过程 if (object_id(proc_cursor, P) is not null) drop proc proc_cursorgocreate proc proc_cursor cur cursor varying outputas set cur cursor forward_only static for select id, name, age from student; open cur;go--调用declare exec_cur cursor;declare id int, name varchar(20), age int;exec proc_cursor cur exec_cur output;--调用存储过程fetch next from exec_cur into id, name, age;while (fetch_status 0)begin fetch next from exec_cur into id, name, age; print id: convert(varchar, id) , name: name , age: convert(char, age);endclose exec_cur;deallocate exec_cur;--删除游标 10、 分页存储过程 ---存储过程、row_number完成分页if (object_id(pro_page, P) is not null) drop proc proc_cursorgocreate proc pro_page startIndex int, endIndex intas select count(*) from product; select * from ( select row_number() over(order by pid) as rowId, * from product ) temp where temp.rowId between startIndex and endIndexgo--drop proc pro_pageexec pro_page 1, 4----分页存储过程if (object_id(pro_page, P) is not null) drop proc pro_stugocreate procedure pro_stu( pageIndex int, pageSize int)as declare startRow int, endRow int set startRow (pageIndex - 1) * pageSize 1 set endRow startRow pageSize -1 select * from ( select *, row_number() over (order by id asc) as number from student ) t where t.number between startRow and endRow; exec pro_stu 2, 2; ? Raiserror Raiserror返回用户定义的错误信息可以指定严重级别设置系统变量记录所发生的错误。 语法如下 Raiserror({msg_id | msg_str | local_variable} {, severity, state} [,argument[,…n]] [with option[,…n]]) # msg_id:在sysmessages系统表中指定的用户定义错误信息 # msg_str:用户定义的信息信息最大长度在2047个字符。 # severity用户定义与该消息关联的严重级别。当使用msg_id引发使用sp_addmessage创建的用户定义消息时raiserror上指定严重性将覆盖sp_addmessage中定义的严重性。 任何用户可以指定0-18直接的严重级别。只有sysadmin固定服务器角色常用或具有alter trace权限的用户才能指定19-25直接的严重级别。19-25之间的安全级别需要使用with log选项。 # state介于1至127直接的任何整数。State默认值是1。 raiserror(is error, 16, 1);select * from sys.messages;--使用sysmessages中定义的消息raiserror(33003, 16, 1);raiserror(33006, 16, 1); 转载于:https://www.cnblogs.com/liyiyong/p/5355736.html
http://www.yutouwan.com/news/467930/

相关文章:

  • 申请手机网站宁乡的网站建设
  • 网站幻灯片js代码淄博便宜网站设
  • 网站seo推广的方法专业展馆展厅设计公司深圳
  • wordpress 更改数据库密码错误seo营销推广费用
  • 如何提高网站收录数无忧网站建设
  • 网站做行业认证好处广告联盟代理平台
  • 企业网站建设是什么实现的物质基础和技术支撑网站建设工作室怎么开
  • 建设公司网站大概需要多少钱济南百度推广电话
  • 云空间布置网站国外大型购物网站
  • 加强机构编制网站建设力度宣威网站
  • 上海什么做网站的公司比较好成都画册设计的公司
  • 设计用哪些网站有哪些功能弄个app要花多少钱
  • 阿里云怎么建设网站衡阳关键词优化首选
  • 兰州做网站的有哪几个学网站建设 去哪里
  • 免费外贸自建网站wordpress页面加载耗时代码
  • 城建道桥建设集团网站wordpress不同分类调用不同文章
  • dw制作网页模板百度网站推广优化工具
  • 安徽富通建设集团有限公司网站推广普通话的广告语
  • 湖州网站建设服务小游戏网站
  • 嘉兴平湖网站建设网站本地环境搭建
  • 如何在学校网站上做链接威海城乡建设局网站首页
  • 网站改版要改哪些页面设置自己的网站
  • 零基础网站开发设计个体工商户做的网站能推广吗
  • 上传网站步骤wordpress占用服务器内存
  • 做局域网网站wordpress社交分享非插件
  • 免费个人网站自助建设云虚拟主机搭建wordpress
  • pc网站转换成微网站购物网站建设计划书
  • 做网站需要怎么样的服务器建设一个地方门户网站
  • 做智能网站系统下载西安月子中心网站制作
  • 2_ 如何写一份详细的网站开发方案成都房产网最新楼盘