JAYRAM

JAYRAM

  • NA
  • 272
  • 215.4k

.plz write storedprocedure quarie display only distinct name

Mar 19 2013 2:07 AM
below my stored procedure display all duplicate values   ......plz write storedprocedure quarie display only distinct names..



storedprocedure....

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER Proc [dbo].[Register_List]
(
@flag int=null,
@srch varchar(max)=null
)
as
begin
if(@flag=1)
begin
select R.SNO,
R.IdNo,
R.SurName,
R.MiddleName,
R.LastName,
R.FatherName,
CONVERT(nvarchar,R.DOB,106)as DOBs,
R.Sex,
R.DNO,
R.Street,
R.Colony,
R.Location,
Mc.MasterName as City,
Md.MasterName as District,
R.Pin,
R.LandLine,
R.Mobile,
R.Email,
R.Qualification,
R.Occupation,
R.Voter,
R.Locality,
R.StationNo,
R.VoterIdNo,
R.VoterSerailNo,

R.ReferMemberId,
R.ReferSurName,
R.ReferMiddleName,
R.ReferLastName,
M.MasterName as Category ,
M.MasterName as ReferType,
R.Localityinterest,
CONVERT(nvarchar,R.CreatedOn,106)as crt,
CONVERT(nvarchar,R.Marriage_Date,106)as Marriage_Date,
R.Division
from Registration R
left join tblMaster M on(R.Category=M.MasterId)
left join tblMaster Mc on(R.City=Mc.MasterId)
left join tblMaster Md on(R.District=Md.MasterId)
where MiddleName like + '%' + @srch +'%'
end

Answers (1)