How to save a file in a field in SQL Server?

1

I would like to know how to save a file within a SQL Server com C# field. Reading in some forums I realized that there is a difference between image files and binaries.

The type of file I want to save is Outlook e-mail. I'm making a system where the records need to have some evidence, and these tests would be the emails I need to keep.

How do I do this? Thanks!

    
asked by anonymous 02.12.2014 / 18:38

1 answer

2

Using the column type FILESTREAM .

Here's a tutorial on setting up your SQL Server to use FILESTREAM .

You can create tables with columns of files like this:

CREATE TABLE MinhaTabela
(
    [Id] [int] primary key identity, 
    [Arquivo] VARBINARY(MAX) FILESTREAM NULL
)
GO

Here is a walkthrough of how to open a file and save it in the database .

    
02.12.2014 / 19:14