views:

131

answers:

4

Can I safely store a .Net compressed memory stream (System.IO.Compression) in an SQLServer 2005 NVARCHAR(MAX) field? SQLServer 2008 is not an alternative.

+4  A: 

Use VARBINARY(MAX) for binary data - VARCHAR(MAX) and NVARCHAR(MAX) are for character-data (strings).

marc_s
Argh - you beat me too it (+1 for you)
David Kemp
A: 

You'd be better off using varbinary(max)

David Kemp
A: 

I would think varbinary(max) is more suitable. Remember that there is a max size of 2GB.

klausbyskov
+1  A: 

A Stream is just a pointer to data, so you cannot store the stream into SQL Server, you can store the data that this stream points to. As you mention the System.IO.Compression namespace I suppose you mean either DeflateStream or GZipStream which both contain binary data. The appropriate type to store binary data in SQL is VARBINARY(MAX).

Darin Dimitrov