1

I am using SQL query to pull some student records from SQL database. I am getting the error Arithmetic overflow error converting expression to data type datetime. It looks like there is a column for student number which is char(15) type and throwing this error every time I put a letter in front of the student number (we have students with this case).

This works fine

Select * from StudentDataTable where StudentNumber = '123456789'

This throws the error

Select * from StudentDataTable where StudentNumber = 'A12345678'

Any help would be appreciated.

tony
  • 1,309
  • 3
  • 10
  • 12
  • 4
    There is nothing in your queries shown that would even be trying to convert to a datetime. Please show the real query. We cannot help you when you oversimplify the problem. – HLGEM Jun 06 '11 at 14:43

1 Answers1

0

SQL is converting the student number to an integer in the background, so your first examples works, but your second one won't. Check what data-type student number is, it should be numeric type, INT, BIGINT etc..

Also, you should be querying without the quotes for the student number, saves SQL converting

Select * from StudentDataTable where StudentNumber = 123456789
Jason Jong
  • 4,310
  • 2
  • 25
  • 33