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