lundi 30 novembre 2015

select single row in sql server with a condition that selects more than one row

MyTable that i want to select the data from

if exists(select * from MyTable where ActChildID_FK = @actid_fk)

begin

declare @parentid int,@fnname nvarchar(100)

select @parentid = ActParentID_FK from MYTabe where ActChildID_FK = @actid_fk

END

the problem is that when the ActChildID_FK = 300374 it returns 2 values for the ActParentID_FK , i need to be able to receive only one value and i do not want to change any of the values in my table. Thanks in advance for any appreciated help.

Aucun commentaire:

Enregistrer un commentaire