How to get the number of characters occupied in particular column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siva125
    New Member
    • Feb 2010
    • 9

    How to get the number of characters occupied in particular column

    I use this query for my table but it retrives the value for each row. It does not retrieve the size of the column name. I need to know the number of characters occupied in particular column. How do i get this value?

    SELECT LEN(salary) AS MyLength FROM employee
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    Extending your query a bit..
    Code:
    SELECT LEN(salary) AS MyLength FROM employee GROUP BY salary

    Comment

    • siva125
      New Member
      • Feb 2010
      • 9

      #3
      Originally posted by ThatThatGuy
      Extending your query a bit..
      Code:
      SELECT LEN(salary) AS MyLength FROM employee GROUP BY salary
      hi,
      i need the columnname salary varchar (i.e) size of that field

      Comment

      • ThatThatGuy
        Recognized Expert Contributor
        • Jul 2009
        • 453

        #4
        Originally posted by siva125
        hi,
        i need the columnname salary varchar (i.e) size of that field
        Code:
        select sc.[length] from sysobjects so inner join syscolumns sc on so.id=sc.id where so.[name]='<table_name>' and sc.[name]='<column_name>'
        this will do

        but make sure the correct database is selected

        Comment

        Working...