



CREATE PROCEDURE DBO.CopyArrangementLineNotes  @SourceArrLine int,  @DestArrLine int  AS
SET NOCOUNT ON

Declare @note varchar (4000)

--311001 NOT USED ANYMORE
/*
          Declare @ArrangementLinksText char (30)
          Declare @LastLinkNumber int

          select * from arrangementLinks (nolock) where arrangementlinenumber=@DestArrLine
          if @@RowCount > 0
             select @LAstLinknumber = (select Max(ArrangementLinksNumber) from arrangementLinks (nolock) where arrangementlinenumber=@DestArrLine) 
          else
            select @LAstLinknumber = 0           
          if @LastLinkNumber is null 
            select @LastLinkNumber=0 --in case...

          Declare CopyLinks Cursor For
          SELECT Text FROM ArrangementLinks (nolock)  where arrangementLineNumber = @SourceArrLine
          Open CopyLinks
          Fetch Next From CopyLinks
          Into @arrangementLinksText
          While  (@@FETCH_STATUS = 0)
          Begin
            set @LastLinkNumber = @LastLinkNumber +1
            Select ArrangementLinenumber from arrangementLinks (nolock) where arrangementlinenumber=@DestArrLine and ArrangementLinksNumber=@LastLinkNumber and Text = @arrangementLinksText
            if @@RowCount = 0 
              Insert into arrangementlinks values (@DestArrLine,@LastLinkNumber,@arrangementLinksText)
            Fetch Next From CopyLinks Into @ArrangementLinksText
          end
          Close CopyLinks
          Deallocate CopyLinks
*/
         select @note = note from arrangementlines WITH (nolock) where arrangementlinenumber = @SourceArrLine
         if @note is not null
          Update arrangementlines set note = Cast(note as Varchar(4000)) + @note where arrangementlinenumber = @DestArrLine

