查找与SQL存储过程中传递的ref关联的匹配行

查找与SQL存储过程中传递的ref关联的匹配行,sql,tsql,stored-procedures,Sql,Tsql,Stored Procedures,我希望在存储过程中传递一个引用号,该存储过程将为我提供所有其他引用号,这些引用号在传入的引用号中具有匹配的名称和地址 如果我通过下表中的27分 RefNo Name Address 47 ABC CBA 27 ZYX XYZ 46 LKJ JKL 745 ZYX

我希望在存储过程中传递一个引用号,该存储过程将为我提供所有其他引用号,这些引用号在传入的引用号中具有匹配的名称和地址

如果我通过下表中的27分

RefNo         Name                Address
47            ABC                 CBA
27            ZYX                 XYZ
46            LKJ                 JKL
745           ZYX                 XYZ
3456          LKJ                 JKL
364           ZYX                 XYZ
我希望存储过程返回27、745和364。

create procedure proc1   
 @ref int
as

select a.refno from table1 a
inner join table1 b
  on a.name=b.name and a.address = b.address
where b.refno=@ref