Finding MAX value from emp_id column using SQL query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gurpreet Singhh
    New Member
    • Mar 2011
    • 10

    Finding MAX value from emp_id column using SQL query?

    I need to select maximum of the Emp_id values from SQL server 2005 table.I was using the command which selects max value till 10 but after that it fails to pick max value of emp id from the table.(Actually it picks up Max value using by looking at 1st digit only,so till 9 its fine, but after that it shows 9>11 or 9>57 etc.So please tell me SQL query for finding max value in Emp id column.Thanx.
    MY sql query used:-
    Code:
        select MAX(emp_id) from table_name
  • gpl
    New Member
    • Jul 2007
    • 152

    #2
    Im guessing that your emp_id column is not a numeric one!

    Assuming that it only holds digits, try
    select max(convert(int , emp_id)) from table_name

    Or convert the whole column to a numeric type .. in future, it would be helpful if you posted the table definition too!

    Comment

    • Gurpreet Singhh
      New Member
      • Mar 2011
      • 10

      #3
      thank you sir...problem solved.thanx a lot brother

      Comment

      Working...