Temple Naylor Temple Naylor - 1 month ago 13
SQL Question

Error of conversion in Microsoft SQL Server

I created a database from the following flow chart: https://www.learncodinganywhere.com/learningmanagementsystem/links/07_DB/SQL_Drill.pdf

I am trying to retrieve the book title, borrower name, and borrower address in my 'Booksville' library branch where the due date is today. I created the following query:

SELECT
Title, b.[Name], b.[Address] as 'Due Today'
FROM
BORROWER b
JOIN
BOOK_LOANS bl ON b.CardNo = bl.CardNo
JOIN
LIBRARY_BRANCH lb ON lb.BranchId = bl.CardNo
JOIN
BOOK bk ON bk.BookId = bl.BookId
WHERE
BranchName = 'Booksville'
AND DueDate = '10-25-2016'


But I get the following error message:


Msg 248, Level 16, State 1, Line 1

The conversion of the varchar value '5397270262193419' overflowed an int column.


Anyone know the solution to this?

Answer

Ok there is information enought, but usually you get this error comparing numeric and alphanumeric fields.

I don't know the table schema but it seems there is mistake here:

on lb.BranchId=bl.CardNo

BranchId should match CardNo?