Lenght of a string

  • How do i find the lenght of a string in a column.. ?

  • Check out LEN() and/or DATALENGTH() in BOL.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Here's one example from BOL...

    USE pubs
    GO
    SELECT length = DATALENGTH(pub_name), pub_name
    FROM publishers
    ORDER BY pub_name
    GO
    

    And just in case you want to find what the max length for the specified column in the DDL is, you could always do..

    SELECT TABLE_NAME, COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS 
    WHERE TABLE_NAME = 'myTable'
    







    **ASCII stupid question, get a stupid ANSI !!!**

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply