Is there a big technical difference between VARBINARY(MAX) and IMAGE data types?

前端 未结 4 1411
南方客
南方客 2020-12-18 20:19

I was reading on internet these statements about SQL Server data types:

  1. VARBINARY(MAX) - Binary strings with a variable length

相关标签:
4条回答
  • 2020-12-18 20:46

    They store the same data: this is as far as it goes.

    "image" is deprecated and has a limited set of features and operations that work with it. varbinary(max) can be operated on like shorter varbinary (ditto for text and varchar(max)).

    Do not use image for any new project: just search here for the issues folk have with image and text datatypes because of the limited functionality.

    In fact, VARBINARY can store any data that can be converted into a byte array, such as files, and this is the same process that IMAGE data type uses, so, by this point of view, both data types can store the same data. But VARBINARY have a size property, while IMAGE accepts any size up to the data type limits, so when using IMAGE data type, you will spend more resources to store the same data. In a Microsoft® SQL Server®, the IMAGE data type is really deprecated, then you must bet in VARBINARY data type.

    But be carefull: The Microsoft® SQL Server® CE® (including the latest 4.0 version) still using IMAGE data type and probably this data type will not "disappears" so soon, because in Compact Edition versions, this data type is better than any other to fast files storage.

    0 讨论(0)
  • 2020-12-18 20:47

    I think that technically they are similar, but it is important to notice the following from the documentation:

    ntext, text, and image data types will be removed in a future version of MicrosoftSQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.

    Fixed and variable-length data types for storing large non-Unicode and Unicode character and >binary data. Unicode data uses the UNICODE UCS-2 character set.

    0 讨论(0)
  • 2020-12-18 20:51

    They store the same data: this is as far as it goes.

    "image" is deprecated and has a limited set of features and operations that work with it. varbinary(max) can be operated on like shorter varbinary (ditto for text and varchar(max)).

    Do not use image for any new project: just search here for the issues folk have with image and text datatypes because of the limited functionality.

    Examples from SO: One, Two

    0 讨论(0)
  • 2020-12-18 21:06

    I inadvertently found one difference between them. You can insert a string into an image type but not into a varbinary. Maybe that's why MS is deprecating the image type as it really doesn't make sense to set an image with a string.

    0 讨论(0)
提交回复
热议问题