> Mike John
>
> "tshad" <tfs@dslextreme.com> wrote in message
> news:%236K0MXDEGHA.644@TK2MSFTNGP09.phx.gbl...
> > "Roji. P. Thomas" <thomasroji@gmail.com> wrote in message
> > news:uu$nMsCEGHA.3324@TK2MSFTNGP10.phx.gbl...
> >> SELECT Name, Address, Salary, ID
> >> FROM Candidate
> >> WHERE ID = @ID
> >> OR @ID = 0
> >
> > I don't understand how that would work.
> >
> > If a 0 is passed I want to see all the records.
> >
> > If a non-zero is passed I only want records of that type. There would
> > never
> > be an ID of 0.
> >
> > Thanks,
> >
> > Tom
> >>
> >>
> >> --
> >> Roji. P. Thomas
> >> Net Asset Management
> >>
http://toponewithties.blogspot.com > >>
> >>
> >> "tshad" <tfs@dslextreme.com> wrote in message
> >> news:uI7RxbCEGHA.3856@TK2MSFTNGP12.phx.gbl...
> >> > If I have a statement in a Stored procedure such as:
> >> >
> >> > CREATE PROCEDURE GetRecord
> >> > @ID Int
> >> > As
> >> > SELECT Name, Address, Salary, ID
> >> > FROM Candidate
> >> > WHERE ID = @ID
> >> >
> >> > I want to actually setup this procedure to see all records regardless
> >> > of
> >> > @ID
> >> > (in which I would pass ID as 0) or only records which match @ID (when
> >> > <>
> >> > 0).
> >> >
> >> > I would change this to:
> >> >
> >> > CREATE PROCEDURE GetRecord
> >> > @ID Int
> >> > As
> >> > IF (@ID = 0 )
> >> > BEGIN
> >> > SELECT Name, Address, Salary, ID
> >> > FROM Candidate
> >> > END
> >> > ELSE
> >> > BEGIN
> >> > SELECT Name, Address, Salary, ID
> >> > FROM Candidate
> >> > WHERE ID = @ID
> >> > END
> >> >
> >> > Is there another way to do this by using one statement, such as using
a
> >> > Case
> >> > Statement?
> >> >
> >> > Thanks,
> >> >
> >> > Tom
> >> >
> >> >
> >>
> >>
> >
> >
>
>