A table has a varbinary (max) column, I need it to have an entry with 400MB of data in this column.
How do I create this data?
Does the Insert statement have to have the data in full or can I use a loop or a function that manages this data?
A table has a varbinary (max) column, I need it to have an entry with 400MB of data in this column.
How do I create this data?
Does the Insert statement have to have the data in full or can I use a loop or a function that manages this data?
Martin Smith
INSERT INTO [YourTable] (YourFileColumn)
VALUES ( CAST(REPLICATE(CAST(0XFF AS VARBINARY(MAX)),
100 * 1024 * 1024) AS VARBINARY(MAX)))
You can use a OPENROWSET function, for example:
CREATE TABLE Tabela(NomeArquivo nvarchar(100), Arquivo varbinary(max));
GO
INSERT INTO Tabela(NomeArquivo, Arquivo)
SELECT 'Texto.txt' AS NomeArquivo, * FROM OPENROWSET(BULK N'C:\Arquivo.txt', SINGLE_BLOB) AS Arquivo;
GO
Friend, although I'm not exactly answering your question the way you expect it, I think putting a column with up to 400Mb per record in the database does not seem like a good idea.
I would only put one URL in the database and would make this heavy data available somewhere on the internet or intranet accessible through the registered URL. This also allows you to distribute access to these files, migrate them, compress them and reuse them without relying on the database to do things that are not the purpose of it.