Datatype to save excel file in sql server?

I have a table in which there are two columns: 1. import type, 2. Excel import template.

The second column, the Excel Import Template, should store the entire excel file.

How can I save an excel file in a databse ... can I use a binary data type column, convert an excel file to bytes and save it?

Thanks in advance!

+3
source share
3 answers

Yes, you can use a binary file type. VARBINARY(MAX)most likely the best fit.

, " Excel " ( ), , . .NET, - :

var insert = new SqlCommand("INSERT INTO tbl (xls) VALUES (@xls)", conn);
insert.Parameters.AddWithValue("xls", File.ReadAllBytes("template.xls"));
insert.ExecuteNonQuery();
+6
varbinary(max)

Excel , , varchar (max)

IMAGE, MSDN

+1

Excel supports XML preservation. You can use this and save the sheet in an XML data file or varchar (max)

0
source

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


All Articles