1

I need to store image in sql database.For this purpose I have to convert the image into byte array.Since different image will have different size what should I give the maximum column length for the image column while creating the database.

Thanks

Kamil Budziewski
  • 22,699
  • 14
  • 85
  • 105
rampuriyaaa
  • 4,926
  • 10
  • 34
  • 41
  • 1
    [*`ntext`, `text`, and `image` data types will be removed in a future version of SQL 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.*](http://msdn.microsoft.com/en-us/library/ms187993.aspx) – marc_s Sep 10 '13 at 09:21
  • Which DBMS are you using? Postgres? Oracle? SQL Server? Each one has different data types and best practices. –  Sep 10 '13 at 09:22

1 Answers1

5

Use VARBINARY(MAX). This will solve your problem of size. There is an article that can help you. Here you can find it.

Note: Sql Server also contains an Image Data type but as per MSDN site, it is going to be removed from future versions so it is better to go with varbinary.

Dhwani
  • 7,484
  • 17
  • 78
  • 139
  • 1
    The max size for VARBINARY(MAX) is 2 GB of data - 2'147'483'648 bytes. More information refer:http://stackoverflow.com/questions/4948051/read-varbinarymax-from-sql-server-to-c-sharp – Dhwani Sep 10 '13 at 09:31
  • Also this one: http://stackoverflow.com/questions/5723698/max-real-space-in-a-varbinarymax-in-sql-server. Hope my answer satisfy your confusion. Tell me if you need more help – Dhwani Sep 10 '13 at 09:32