SQL 存储过程中的IF_BEGIN_END作用域

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

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐