if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Kardeks]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[Kardeks]

IF EXISTS ( SELECT  *
            FROM    dbo.sysobjects
            WHERE   id = OBJECT_ID(N'[dbo].[Sp_SleepKala]')
                    AND OBJECTPROPERTY(id, N'IsProcedure') = 1 )
    DROP PROCEDURE [dbo].[Sp_SleepKala]


IF EXISTS ( SELECT  *
            FROM    dbo.sysobjects
            WHERE   id = OBJECT_ID(N'[dbo].[Sp_SleepKalaAvg]')
                    AND OBJECTPROPERTY(id, N'IsProcedure') = 1 )
    DROP PROCEDURE [dbo].[Sp_SleepKalaAvg]