Select C.Name, D.CID From Part2_DB.dbo.CharInfo C inner Join Part2_New.dbo.CharInfo D on C.Name = D.Name