Вставить файл @name в таблицу FileTable
в субдиректорию @dir (первый уровень ).
Это работает. Но хочется вставит "прямо". Без update.
Есть идеи?
в субдиректорию @dir (первый уровень ).
Это работает. Но хочется вставит "прямо". Без update.
Есть идеи?
begin transaction; if not exists (select * from TourML.SpoFiles where is_directory = 1 and name = @dir and parent_path_locator is null ) insert TourML.SpoFiles( is_directory, name ) select 1, @dir where not exists (select * from TourML.SpoFiles where is_directory = 1 and name = @dir and parent_path_locator is null ); declare @id table( stream_id uniqueidentifier ); insert TourML.SpoFiles( name, file_stream ) output inserted.stream_id into @id(stream_id) select cast( newid() as nvarchar(255) ), cast( @XML as varbinary(max) ); with fo as ( select path_locator from TourML.SpoFiles where is_directory = 1 and name = @dir and parent_path_locator is null ) , fl as ( select f.* from TourML.SpoFiles as f inner join @id as t on t.stream_id = f.stream_id where f.is_directory = 0 ) update fl set path_locator = fl.path_locator.GetReparentedValue(hierarchyid::GetRoot(), fo.path_locator), name = @name from fl cross join fo; commit transaction;