sql笔记

 一 、查询重复的id记录,和条数 ,这里主要要说明的是having 用法

select  ID,COUNT(ID) from Nationality_Map  group by  ID having COUNT(ID)>=2 ;

二、存储过程中 参数做条件 

   这个不是第一次看见了,但是一直没有弄明白它有何用,今天花时间来实践一下,并把结果写出来,算做一个小记录吧!

  查询 

select * from test

结果

创建存储过程查询

create procedure [dbo].[yy] (  @id int  ) 
as 
begin 
select * from test where  @id=120

执行存储过程结果

修改存储过程查询条件

alter procedure [dbo].[yy] @id int  
as 
begin 
select * from test where  @id>30
end 

执行结果

结果总结得出。参数作where查询条件,要么是查询全部,要么为空。

posted @ 2015-03-27 15:03  山水中华  阅读(262)  评论(0编辑  收藏  举报