As far as I know the maximum value you can define "manually" is 8000
-> varbinary(8000)
which, as far as I know, means 8000 bytes
-> 7,8125 KByte
.
Is it possible to set max to 2 MB
? Something ike varbinary(2097152)
, or shall I set it to varbinary(max)
and check the file size through my upload/sql insert script?
You could use a
CHECK CONSTRAINT
to ensure the size is below 2MB:Then when trying to insert something larger than 2 MB:
You get an error:
There is no provision to specify varbinary(2097152), Once if you cross 8000 bytes,you should go for max keyword only.
It will consume only the memory you need (in your case it is 2MB) and it will store upto 2GB at max.