locked
Column Character-Count RRS feed

  • Question

  • Is there a T-SQL Command that will allow me to SELECT, for example, every ROW where a COLUMN has a specific number of Text Characters? like, 
    SELECT *
    WHERE TEXT_COLUMN (CHARACTERCOUNT>3000)???

    THANKS
    F
    Monday, November 4, 2013 1:14 AM

Answers

  • Thanks Imran, 

    That helped me realize that I wasn't running into a character limit when trying to import a large amount of text into 1 column. 

    I must be reaching the 2GB LIMIT for varchar(max). Is there any way to check the size (gb) of a column, as opposed to character count?

    thanks

    Spatio

    • Marked as answer by spatio Monday, November 4, 2013 4:49 AM
    Monday, November 4, 2013 2:08 AM

All replies

  • Hi Spatio,

    Have you tried using Tsql LEN or DATALENGTH. Here is how you can achieve what you are looking for:

    SELECT *
       FROM TABLE
       WHERE (DATALENGTH (TEXT_COLUMN)/2 > 3000)

    DataLength - TSQL

    Diff between Len and DataLength


    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" Thanks, Imran Abbasi

    • Proposed as answer by Imran I Abbasi Monday, November 4, 2013 1:30 AM
    Monday, November 4, 2013 1:30 AM
  • Thanks Imran, 

    That helped me realize that I wasn't running into a character limit when trying to import a large amount of text into 1 column. 

    I must be reaching the 2GB LIMIT for varchar(max). Is there any way to check the size (gb) of a column, as opposed to character count?

    thanks

    Spatio

    • Marked as answer by spatio Monday, November 4, 2013 4:49 AM
    Monday, November 4, 2013 2:08 AM