随笔分类 - SQL Server
摘要:select * from Awhere id in(select id from B) 以上查询使用了in语句,in()只执行一次,它查出B表中的所有id字段并缓存起来.之后,检查A表的id是否与B表中的id相等,如果相等则将A表的记录加入结果集中,直到遍历完A表的所有记录.它的查询过程类似于以下
阅读全文
摘要:-- ylb:存储过程创建与操作 use pubs go --一、无参存储过程 --1,创建存储过程 create procedure PTitles as select * from titles go --2,执行存储过程 execute PTitles go --3,移除存储过程 --drop
阅读全文
摘要:exists : 强调的是是否返回结果集,不要求知道返回什么, 比如: select name from student where sex = 'm' and mark exists(select 1 from grade where ...) ,只要exists引导的子句有结果集返回,那么exi
阅读全文
posted @ 2016-04-13 21:30
不要太嚣张了
摘要:create proc AddCloumnProc ( @tablename varchar(50), @columnname varchar(50) ) as begin exec ('alter table '+@tablename+' and '+@columnname) end create proc p_test ( @id nvarchar(20),@sex b...
阅读全文
posted @ 2016-04-10 22:41
不要太嚣张了
摘要:什么是存储过程呢?存储过程就是作为可执行对象存放在数据库中的一个或多个SQL命令。 通俗来讲:存储过程其实就是能完成一定操作的一组SQL语句。 那为什么要用存储过程呢?1.存储过程只在创造时进行编译,以后每次执行存储过程都不需再重新编译,而一般SQL语句每执行一次就编译一次,所以使用存储过程可提高数
阅读全文

浙公网安备 33010602011771号