我有一組名爲GreenLine1.mp3,GreenLine2.mp3 e.t.c的音頻文件。我將它們寫入到一個表作爲BLOB(我用的MS SQL Server'08),這裏是我的SQL請求:T-SQL:與字符串concat問題
DECLARE @aud AS VARBINARY(MAX)
DECLARE @num AS INT
-- Load the audio data
SET @num=1
WHILE (@num<38)
BEGIN;
SELECT @aud = CAST(bulkcolumn AS VARBINARY(MAX))
FROM OPENROWSET(
BULK
'C:\Users\Ilya\folder\GreenLine' + CAST(@num AS VARCHAR) + '.mp3',
SINGLE_BLOB) AS x
-- Insert the data to the table
INSERT INTO Mb2.dbo.Audios (Id, [Content])
SELECT NEWID(), @aud
SET @num = @num + 1
END;
我有一個錯誤:附近「+」,希望有語法錯誤「」要麼 ')'。
如果我嘗試寫
'C:\Users\Ilya\folder\GreenLine' + CAST(@num AS VARCHAR) + '.mp3'
到一個變量,並把它BULK後,我得到附近@variable,預計STRING語法不正確,或TEXT_LEX
鏈接已損壞。這就是爲什麼鏈接吸了 – Beanwah
@Beanwah更新。 –