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
------------------------- A little Progress a day makes you a big success... ----------------------------