1
我有一個問題,我的filestream filetable,當我運行一個插入語句,它的文件保存,但file_type列爲空(顯然無法手動更新給予這是一個計算列)問題Filestream Filetable不計算插入的file_type列
DECLARE @counter INT, @maxPolicySectionId INT
DECLARE @name NVARCHAR(128)
DECLARE @file_stream VARBINARY(MAX)
DECLARE @path NVARCHAR(256)
DECLARE @command NVARCHAR(MAX)
DECLARE @fileTable TABLE(
name NVARCHAR(50),
filePath NVARCHAR(128),
polSecId INT
);
--...Populate @fileTable from database table...--
SELECT @counter = MIN(policySectionId), @maxPolicySectionId = MAX(policySectionId) FROM tblPolicySection
SET @name = (SELECT name FROM @fileTable WHERE polSecId = @counter)
SET @path = (SELECT filePath FROM @fileTable WHERE polSecId = @counter)
SET @path = REPLACE(@path, '192.168.0.6', 'meta-filesrv')
--SET @file_type in Filetable somehow.. unable to perform UPDATE because it's a computed column
SET @command = N'SELECT @file_stream1 = CAST(bulkcolumn AS varbinary(MAX))
from OPENROWSET(BULK ''' + @path + ''',
SINGLE_BLOB) AS x'
EXEC sp_executesql @command, N'@file_stream1 VARBINARY(MAX) OUTPUT',@file_stream1 = @file_stream OUTPUT
IF @path IS NOT NULL AND @name IS NOT NULL
BEGIN
INSERT INTO BlobDocStore(
name,
file_stream
)
SELECT
@name,
@file_stream
END
SET @counter = @counter + 1
正如你可以看到我傳遞一個流進插入語句應該努力盡我的理解。我希望過去有人對此有過一些經驗。謝謝。
「@ fileTable」表中沒有'file_type'列。 – Magnus
這只是一個臨時表,用於在插入BlobDocStore之前安排數據,該BlobDocStore具有filetable的固定模式。插入數據的唯一兩個必填字段是name和file_stream,除非我錯了,並且應根據這些文件類型生成文件類型? – bjjrolls