Optimum Store Procedure

Last Reply on Mar 25, 2013 04:44 AM By RkHirpara

Posted on Mar 25, 2013 02:05 AM

HI

below code is my SP

how I can it worked correctly but I want Optimum it How I can do it?

thanks

 

 

 

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Search_number]
@Mobile nvarchar(15)
as
begin
SET NOCOUNT ON

select (select Ownername from House_Info where Mobile=@Mobile or Tell=@Mobile) as Name,(select Mobile from House_Info  where Mobile=@Mobile or Tell=@Mobile) as Mobile,
(select BehcodeN from House_Info where Mobile=@Mobile or Tell=@Mobile) as BehcodeN,(select ID from House_Info  where Mobile=@Mobile or Tell=@Mobile) as Id,
(select BehCode from House_Info where Mobile=@Mobile or Tell=@Mobile) as BehCode,(select Variz from House_Info where Mobile=@Mobile  or Tell=@Mobile) as Variz,
(select Variz from House_Info where Mobile=@Mobile or Tell=@Mobile) as Variz,(select Code from House_Info where Mobile=@Mobile or Tell=@Mobile ) as Code



,(select Tell from Varizpool where Tell=@Mobile ) as NVariz,(select Mobile from Black_list where Mobile=@Mobile ) as MobileB,
(select BehcodeN from free_register where Mobile=@Mobile ) as Freg,(select BehcodeN from S_register where Mobile=@Mobile ) as Sreg,
(select Mobil from Estate_free where Mobil=@Mobile ) as Fregestate,(select Aname from Black_list where Mobile=@Mobile ) as NameB,
(select Aname from S_register where Mobile=@Mobile ) as Aname,(select Mobile from S_register where Mobile=@Mobile ) as MobileSR
,(select Mobile from free_register where Mobile=@Mobile ) as MobileFR,(select Name from Varizpool where Tell=@Mobile ) as NameV
,(select tell from Varizpool where tell=@Mobile ) as MobileV,(select Name from Estate_free where Mobil=@Mobile ) as NameE



end

 

Posted on Mar 25, 2013 04:44 AM

Hi Nedash,

You can repace all this inner quries by INNER JOIN but for this you needs all involved table in relation by primaty key - foreign key.

Thanks and Regards,

Rk_Hirpara.