蝸牛漫步

2011年2月19日

存储过程分页

摘要: alter proc proc_Customers_pageindex( @pageindex int, @pagesize int,@count int output)as select @count=count(*) from Customers select * from ( select row_number() over(order by CustomerID) as 'rowindex',* from Customers) as Customers_pageindex where rowindex>@pageindex*@pagesize and rowindex<=( 阅读全文

posted @ 2011-02-19 22:56 蝸牛漫步 阅读(181) 评论(0) 推荐(1) 编辑

什么是事务?

摘要: 事务:就是被绑定在一起作为一个逻辑工作单元的SQL语句分组,如果任何一个语句操作失败那么整个操作就被失败,以后操作就会回滚到操作前状态,或者是上有个节点。为了确保要么执行,要么不执行,就可以使用事务。要将有组语句作为事务考虑,就需要通过ACID测试,即原子性,一致性,隔离性和持久性。案例:create procedure p4(@From varchar(20),@To varchar(20),@nums money)asdeclare @error intset @error=0begin transactionupdate bank set price=price-@nums where 阅读全文

posted @ 2011-02-19 19:07 蝸牛漫步 阅读(140) 评论(0) 推荐(1) 编辑

什么是存储过程

摘要: 存储过程存储过程(Stored Procedure)是一组为了完成特定功能的SQL语句集,经编译后存储在数据库中。用户通过指定存储过程的名字并给出参数(如果该存储过程带有参数)来执行它。存储过程是数据库中的一个重要对象,任何一个设计良好的数据库应用程序都应该用到存储过程。总的来说,存储过程具有以下一些优点: ◆存储过程允许标准组件式编程 ◆存储过程能够实现较快的执行速度 ◆存储过程能够减少网络流量 ◆存储过程可被作为一种安全机制来充分利用 --9.修改上例,返回未通过考试的学员人数。alter procedure p2(@nopassNums int output,-- 参数设置默认值@wri 阅读全文

posted @ 2011-02-19 19:02 蝸牛漫步 阅读(202) 评论(0) 推荐(1) 编辑

什么是T-SQL?

摘要: T-SQLSQL 程式设计语言的增强版,它是用来让应用程式与 SQL Server 沟通的主要语言。T-SQL 提供标准 SQL的DDL 和 DML 功能,加上延伸的函数、系统预存程序以及程式设计结构(例如 IF 和 WHILE)让程式设计更有弹性。案例:--1.显示李文才的左右同桌(stu)declare @seat intselect @seat=stuSeat from stu where stuName='李文才'select * from stu where stuSeat in(@seat-1,@seat+1)--2.统计并显示本班笔试平均分,如果平均分在70以上--显示&ldqu 阅读全文

posted @ 2011-02-19 18:30 蝸牛漫步 阅读(785) 评论(0) 推荐(0) 编辑

导航