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
2009-12-01 13:14:34
Argh - you beat me too it (+1 for you)
David Kemp
2009-12-01 13:16:11
A:
I would think varbinary(max) is more suitable. Remember that there is a max size of 2GB.
klausbyskov
2009-12-01 13:16:18
+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
2009-12-01 13:17:05