当前位置: 移动技术网 > IT编程>数据库>MSSQL > SQL 存储过程中的IF_BEGIN_END作用域

SQL 存储过程中的IF_BEGIN_END作用域

2018年11月28日  | 移动技术网IT编程  | 我要评论

赵晓柔,广西摩托大军返乡,乐巢汇论坛

use [db_name]
go

set ansi_nulls on
go
set quoted_identifier on
go


alter procedure [dbo].[proc_test_if_begin end]
as
begin

set nocount on;

if (day(getdate())=1)
begin
print 'a'
end

if (day(getdate())=19)
begin
print 'a19'
end


if (day(getdate())=20)
begin
print 'aaaa20'
end

if object_id('tempdb..#base') is not null
begin
print 'b'
end

end

  假设今天是19号, 执行存储过程 exec proc_test_if_begin end

得到什么?

答案:a19

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网