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.
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