0

i am facing a slite problem in sql server 2008 and here is the situation

IF @PatCntFamNbr is not null 
BEGIN

select  t.Cntid AS Center , t.PatFName AS FirstName   , t.PatMName AS MiddleName , t.PatLName AS     LastName  
from tblpatient t INNER JOIN  TblPatientCentres p
 ON   p.PatID_fk = t.PatId_PK
where   p.CentreID_fk=@cntid  and @patid in (select patid_fk from tblpatientcentres where cntfammbnbr=@cntfammbnbr)
END

my major problem is that this must show lots of names that belongs to the same family and the variable @patis is accepting only one variable and this is not allowing the procedure to work properly

i will be really thankful for any help

1 Answer 1

1

If you need a variable that can hold multiple values then you should use a Table Variable
IE something like DECLARE @patid TABLE(ID INT)

If you need the variable to be passed in via a client application then research table valued types

However your query doesnt look like it needs either - it just needs fixing...

IF @PatCntFamNbr is not null 
BEGIN

select  t.Cntid AS Center , t.PatFName AS FirstName   , t.PatMName AS MiddleName , t.PatLName AS     LastName  
from tblpatient t INNER JOIN  TblPatientCentres p
 ON   p.PatID_fk = t.PatId_PK
where   p.CentreID_fk=@cntid  and p.cntfammbnbr=@cntfammbnbr -- this is all you need
END
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.