Print ''
Print '---------------------------------------------------------------------------------------'
Print ' using Database: #DB_N#'
Print ' Procedures    : [REPORTS Customer GB]'
Print ' Creation      : 24.02.2015 15:14/J.Fes'
Print ' Last.Update   : 24.02.2015 15:14/J.Fes'

use [#DB_N#]

--------------------------------------------------------------------------------
Print '-- [Report_910_GB_ListObjectDubliates] --------------------------------------'
If Exists (select Name from sysobjects where type = "P" and
           Name = "Report_910_GB_ListObjectDubliates")
Drop Procedure Report_910_GB_ListObjectDubliates
GO
CREATE PROCEDURE Report_910_GB_ListObjectDubliates
       (
        @ObjectFromSiteID nvarchar(32) ,
        @ProcStateCol nvarchar(14),
        @ObjectClass nvarchar(10)
       )


AS
begin
SELECT DISTINCT ObjectName from (
SELECT ObjectName,
  rn = ROW_NUMBER()
  over (partition by
  ObjectName
  order by ObjectName)
FROM dbo.Objects_tbl
  WHERE
      ObjectClass = @ObjectClass
  and ObjectFromSiteID = @ObjectFromSiteID ) as tbl
WHERE rn > 1
end
GO

Print ''
Print '---------------------------------------------------------------------------------------'
Print ' R E P O R T S imported to #DB_N#'
Print '---------------------------------------------------------------------------------------'
GO
