Solved

binary data datatype

Posted on 2012-03-11
3
334 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:
ewangoya 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
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.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now