SQL IF..ELSE..在存储过程的使用规范
2007-02-08 09:39
246 查看
CREATE PROCEDURE [dbo].[sp_stat_info]
(
@city nvarchar(20),
@town nvarchar(20),
@village nvarchar(20)
)
as
declare @num numeric(10)
declare @yd_num numeric(10)
declare @lt_num numeric(10)
declare @gh_num numeric(10)
declare @xlt_num numeric(10)
select @num=count(jmzh) from jfxd.t_gongan_end_2
if @city='aaa'
begin
select @yd_num=count(jmzh) from jfxd.t_gongan_end_2 where SERIAL_NUMBER is not null
select @lt_num=count(jmzh) from jfxd.t_gongan_end_2 where unicom is not null
select @gh_num=count(jmzh) from jfxd.t_gongan_end_2 where tel is not null
select @xlt_num=count(jmzh) from jfxd.t_gongan_end_2 where little_tel is not null
end
else if @town='bbb'
begin
//sql语句
end
else
begin
//sql语句
end
update t_stat_info set……
GO
(
@city nvarchar(20),
@town nvarchar(20),
@village nvarchar(20)
)
as
declare @num numeric(10)
declare @yd_num numeric(10)
declare @lt_num numeric(10)
declare @gh_num numeric(10)
declare @xlt_num numeric(10)
select @num=count(jmzh) from jfxd.t_gongan_end_2
if @city='aaa'
begin
select @yd_num=count(jmzh) from jfxd.t_gongan_end_2 where SERIAL_NUMBER is not null
select @lt_num=count(jmzh) from jfxd.t_gongan_end_2 where unicom is not null
select @gh_num=count(jmzh) from jfxd.t_gongan_end_2 where tel is not null
select @xlt_num=count(jmzh) from jfxd.t_gongan_end_2 where little_tel is not null
end
else if @town='bbb'
begin
//sql语句
end
else
begin
//sql语句
end
update t_stat_info set……
GO
相关文章推荐
- msSQL存储过程中使用 IF ELSE 的规范示例
- SQL IF..ELSE..在存储过程的使用规范
- SQLIF..ELSE..在存储过程的使用规范
- SQL IF..ELSE..在存储过程的使用规范
- SQL IF..ELSE..在存储过程的使用规范
- SQL IF..ELSE..在存储过程的使用规范
- 存储过程中If Else的使用方法
- 存储过程中If Else的使用方法
- 存储过程中If Else的使用方法
- java中使用sql的存储过程,提高查询效率
- SQL Server存储过程中使用事务
- 使用SQLSERVER的扩展存储过程实现远程备份与恢复(转载)
- C#存储过程的使用
- mysql存储过程中使用事件
- 存储过程的创建及使用(sqlserver 2005)
- Mysql存储过程------存储过程的基本概念和基本使用方法
- 如何在Oracle中使用Java存储过程(详解)
- MySQL存储过程使用实例详解
- Oracle存储过程中如何使用游标
- 第三章——使用系统函数、存储过程和DBCC SQLPERF命令来监控SQLServer(3)