|
Posted by Ed Murphy on 11/02/07 02:22
danko.greiner@gmail.com wrote:
> I have structure:
>
> FolderId, FolderName, ParentFolderId, FullPath
>
> e.g.
>
> 1, First, null, First
> 2, Sec, 1, First/Sec
> .....
>
> When update happens to FolderName, i need to update all FullPaths that
> are below Folder which is changing.
Untested:
declare @FolderId int
set @FolderId = 2
declare @FolderName varchar(10)
set @FolderName = 'Zwei'
update the_table
set FolderName = @FolderName
where FolderId = @FolderId
while 1 = 1
begin
update the_table
set c.FullPath = p.FullPath + '/' + c.FolderName
from the_table c
join the_table p on c.ParentFolderId = p.FolderId
where c.FullPath <> p.FullPath + '/' + c.FolderName
if @@rowcount = 0
break
end
Navigation:
[Reply to this message]
|