title: There is already an object named '#result' in the database
body: <pre><code>Alter Procedure sp_Member(
    @comcode int = 0,
    @SubComCode int = 0
  )
  as begin
    set nocount on
    If @comcode='0'
    begin
      select (
        select sum(amount)
          from tbcoudet
          where memcode=tbm.memcode and
                expyear=(select max(expyear) from tbexpyear)
                and exists (
                  select itemcode
                  from tbitem
                  where comcode=@comcode and
                    SubComCode=@SubComCode and
                    itemcode=tbcoudet.itemcode
                )
          group by memcode,expyear
        )'TurnOver', *
      into #result from tbmember tbm where can_flag='N'
    end
    If @subcomcode='0'
    begin
      select (
        select sum(amount)
        from tbcoudet
        where memcode=tbm.memcode and expyear=(select max(expyear) from tbexpyear)
          and exists (
            select itemcode
            from tbitem
            where comcode=@comcode and
              itemcode=tbcoudet.itemcode
          )
        group by memcode,expyear
      )'TurnOver', *
      into #result from tbmember tbm where can_flag='N'
    end
  
    select top 10 * from #result where TurnOver is not null order by TurnOver desc
  end
  </code></pre>
  
  <p>That is my sql code and when i am going to execute store procedure then I get the error</p>
  
  <pre><code>There is already an object named '#result' in the database.
  </code></pre>
  
  <p>Can anyone tell me what the problem is?</p>