Solved

binary data datatype

Posted on 2012-03-11
3
347 Views
Last Modified: 2012-03-16
We want to serialize some of our c# classes into a database column.  We are going to use binary serialization.  
What would be the best datatype to store the binary data?  Should we use varbinary(max)?  The classes are not very large and when serializing to the file system they are about 7Kb.
Any suggestions?

CREATE TABLE [dbo].[ClassTable](
      [ID] [int] NOT NULL,
      [ClassData] [varbinary](max) NOT NULL,
 CONSTRAINT [PK_ClassTable] PRIMARY KEY CLUSTERED
(
      [ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
0
Comment
Question by:tampsystems
3 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 500 total points
ID: 37708571
varbinary(max) is your best bet, since you don't know before hand what size you would need in the future
0
 

Author Comment

by:tampsystems
ID: 37709299
now what if we need to store it using text (XML), would varchar(max) be the best bet too?
0
 
LVL 25

Expert Comment

by:jogos
ID: 37709530
If you only want to use it trough your C# it don't makes a lot of difference.

There is also the XML-datatype, but that will be slower in performance.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Star schema daily updates 2 34
Need sql in string 2 29
SQL Server Sum Over Multiple Tables 20 32
Inserting LocalDB Table to SQL Server C# 3 14
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question