Skip to content
Advertisement

How should I insert video in SQL Server with column of description?

I have tables with two columns: Video and desc. I want to insert video in SQL Table. I use next script:

INSERT INTO table(Video)
 SELECT ( SELECT BulkColumn FROM OPENROWSET(BULK 'sourcevideo.mp4', SINGLE_BLOB) AS x)

but I want also insert some description, so I imagine it like

INSERT INTO table(Video, desc)
 (SELECT ( SELECT BulkColumn FROM OPENROWSET(BULK 'sourcevideo.mp4', SINGLE_BLOB) AS x) , some_description)

How should I implement it?

UPD What if description is the .txt file? What should I do in this case?

Advertisement

Answer

Why are you nesting the select?

INSERT INTO table (Video, description)
    SELECT BulkColumn, 'my description here'
    FROM OPENROWSET(BULK 'sourcevideo.mp4', SINGLE_BLOB) as x
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement