Cari Blog Ini

28 Juni 2012

How To Validate Availability of Stored Procedure in Database using EXISTS

----------------------------------------------------------------------------------
-----code:start
----------------------------------------------------------------------------------
IF EXISTS
(
    SELECT [name] FROM sysobjects
    WHERE
        [name]='sp_PerTahun_Jumlah_Kelompok_Umur_Loop'
        and type='P'
)

BEGIN
    SELECT '-----Stored Procedure: sp_PerTahun_Jumlah_Kelompok_Umur_Loop is available-----'
END
----------------------------------------------------------------------------------
-----code:end
----------------------------------------------------------------------------------

Result Messages:
------------------------------------------------------------------------------
-----Stored Procedure: sp_PerTahun_Jumlah_Kelompok_Umur_Loop is available-----

(1 row(s) affected)