Link to home
Start Free TrialLog in
Avatar of fwstealer
fwstealerFlag for United States of America

asked on

find matches between two tables

need to find all rows from drive where the driveid is in the expensereport table

select drives.driveid as 'Apple.drives.driveID', ExpenseReport.driveID as 'Po.ExpenseReport.driveID'
from ExpenseReport with(nolock)
inner join aserver.apple.dbo.drives drive with(nolock) on ExpenseReport.driveID = drive.driveid
where drive.driveid = ExpenseReport.driveID

my error: Error on the 1st line: Conversion failed when converting the varchar value 'No  send me to confirmation page now' to data type int.
Avatar of BuggyCoder
BuggyCoder
Flag of India image

select a.* from expensereport a inner join drives b
on a.driveid=b.driveid

Open in new window

Avatar of Scott Pletcher
Wouldn't that still give you the same error??
<< Conversion failed when converting the varchar value 'No  send me to confirmation page now' to data type int>>
I don't see a column  'No  send me to confirmation page now' in your query. So I think there is a view involved that isn't correct.
This is because the data type of DriveID do not match between Drive table and ExpenseReport table.
ASKER CERTIFIED SOLUTION
Avatar of agusacil
agusacil
Flag of Indonesia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial