0

我正在尝试检查存储过程是否存在,然后我需要执行它。当我尝试这个时,我在 if 部分遇到错误:

use [ST_Analysis]
GO
/***** Object:  StoredProcedure [dbo].[sp_CleanRelogTables]  
INPUT PARAMETERS
none
*****/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

IF NOT EXISTS(SELECT  name FROM sysobjects WHERE name = 'sp_CleanRelogTables' 
              AND type = 'P')
begin
    CREATE PROCEDURE [dbo].[sp_CleanRelogTables]
    AS
    BEGIN
        SET NOCOUNT ON
        TRUNCATE TABLE COUNTERDATA
        TRUNCATE TABLE COUNTERDETAILS
        SET NOCOUNT OFF
    END
end
Else
    execute sp_CleanRelogTables
4

0 回答 0