你参考一下吧:
CREATE PROCEDURE Kid_User_Search
(
@Chose_Type nvarchar(16),
@Select_Type nvarchar(16),
@Nvch_DID nvarchar(20),
@Keyword varchar(16),
@Result nchar(20)=''output
)
AS
if @Select_Type = 'Y'
begin
if @Keyword <> ''
begin
if @Chose_Type = '0'
begin
select * from UserInfo where Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '1'
begin
select * from UserInfo where Name like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '2'
begin
select * from UserInfo where Nicheng like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '3'
begin
select * from UserInfo where Province like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '4'
begin
select * from UserInfo where RegDate like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '5'
begin
select * from UserInfo where Sex like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '6'
begin
select * from UserInfo where Nvch_SN like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
end
if @Keyword = ''
begin
select * from UserInfo where Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
end
if @Select_Type = ''
begin
select * from UserInfo where Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
GO
CREATE PROCEDURE Kid_User_Search
(
@Chose_Type nvarchar(16),
@Select_Type nvarchar(16),
@Nvch_DID nvarchar(20),
@Keyword varchar(16),
@Result nchar(20)=''output
)
AS
if @Select_Type = 'Y'
begin
if @Keyword <> ''
begin
if @Chose_Type = '0'
begin
select * from UserInfo where Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '1'
begin
select * from UserInfo where Name like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '2'
begin
select * from UserInfo where Nicheng like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '3'
begin
select * from UserInfo where Province like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '4'
begin
select * from UserInfo where RegDate like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '5'
begin
select * from UserInfo where Sex like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
if @Chose_Type = '6'
begin
select * from UserInfo where Nvch_SN like '%'+@Keyword+'%' and Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
end
if @Keyword = ''
begin
select * from UserInfo where Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
end
if @Select_Type = ''
begin
select * from UserInfo where Nvch_SN in (select Nvch_SN from Kid_Card where Nvch_Dealer = @Nvch_DID)
end
GO
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货