IMAGE Data Type
Note: The IMAGE
data type is deprecated. Microsoft recommends using VARBINARY(MAX)
for new development.
Synopsis
The IMAGE
data type stores variable-length binary data up to 2,147,483,647 bytes (2 GB). It is often used to store pictures, graphics, or other large binary objects.
Syntax
column_name IMAGE [NULL | NOT NULL]
Example Usage
-- Create a table with an IMAGE column
CREATE TABLE dbo.ProductImages
(
ProductID INT PRIMARY KEY,
ImageData IMAGE NULL
);
GO
-- Insert an image from a file
INSERT INTO dbo.ProductImages (ProductID, ImageData)
SELECT 101, BulkColumn FROM OPENROWSET(BULK N'C:\Images\example.jpg', SINGLE_BLOB) AS img;
GO
-- Retrieve the image
SELECT ProductID, ImageData
FROM dbo.ProductImages
WHERE ProductID = 101;
GO
Properties
Property | Value |
---|---|
Maximum Length | 2,147,483,647 bytes (2 GB) |
Storage | Out-of-row storage if > 8 KB |
Supported in | SQL Server 2000 – 2019 (deprecated in 2008 onward) |
Preferred Replacement | VARBINARY(MAX) |
Related Topics
Version History
SQL Server Version | Status |
---|---|
SQL Server 2000 | Supported |
SQL Server 2005 | Supported (Deprecated) |
SQL Server 2008 | Deprecated |
SQL Server 2012+ | Supported for backward compatibility only |