How can I read file bytes in tsql with server connection?

I use this code to read bytes of a .mp3 file in sql server. When I use a local connection, it works correctly. But when I change the connection to the server (for example: 192.168.1.1 and Windows authentication mode ) and start it, I get an error message.

DECLARE @Table1 TABLE(ID INT, AudioFileName VARCHAR(50),AudioFileColumn VARBINARY(MAX))
INSERT INTO @Table1 (ID, AudioFileName, AudioFileColumn)
SELECT 1, 'Name1', BulkColumn FROM
OPENROWSET (BULK N'\\fs1\Projects\Data\DATABASE\FAQ\File1.mp3', SINGLE_BLOB)  AS x
SELECT * FROM @Table1

error:

Msg 4861, Level 16, State 1, Line 2 Cannot be loaded in bulk because the file "\ fs1 \ Projects \ Data \ DATABASE \ FAQ \ File1.mp3" could not be opened. Operating system error code 5 (could not get the text for this error. Reason: 15105).

How can I solve it?

+4
source share
1

, SQL Server BULK . , . ,

+1

Source: https://habr.com/ru/post/1530807/


All Articles