CREATE procedure [dbo].[DropObject]
@objectname varchar(max), 
@schemaid int
AS
BEGIN
print @objectname
print @schemaid
  DECLARE @ObjectType varchar(max) 
  Set @ObjectType = (SELECT [type] FROM sys.objects WHERE name = @objectname and schema_id = @schemaid)
print @ObjectType  
  DECLARE @DropType varchar(max)
  Set @DropType = ''
  IF @ObjectType IN ('PC', 'P')
    SELECT @DropType = 'PROCEDURE'
  IF @ObjectType IN ('FN', 'FS', 'FT', 'IF', 'TF')
    SELECT @DropType = 'FUNCTION'
  IF @ObjectType = 'AF'
    SELECT @DropType = 'AGGREGATE'
  IF @ObjectType = 'U'
    SELECT @DropType = 'TABLE'
  IF @ObjectType = 'V'
    SELECT @DropType = 'VIEW'
  IF @DropType <> ''
     begin
        DECLARE @schemaName varchar(100)
        SET @schemaName = (SELECT name FROM sys.schemas WHERE schema_id = @schemaid)
        EXEC('DROP '+ @DropType + ' [' + @schemaName + '].[' + @objectname + ']')
     end
END