Query to find the size of data in a column

15,298
SELECT * FROM tbl WHERE DATALENGTH(RawData) > 1048576
Share:
15,298
Derin
Author by

Derin

Updated on November 20, 2022

Comments

  • Derin
    Derin over 1 year

    I have a column called RawData of datatype Image in my table. I need to find all rows where the size of that column is more than 1 MB.

    It would be great if someone could help me with the query for this. I use SQL Server 2008.

    Thanks in advance

    • Harry Joy
      Harry Joy almost 13 years
      try datalength(field) to get size of data and then compare it.
    • marc_s
      marc_s almost 13 years
      IMAGE is deprecated since SQL Server 2005 - use VARBINARY(MAX) instead