if(exists(select * from sysobjects where xtype = 'P' and name = 'CCIVR_GetCusInfo'))
begin
drop procedure CCIVR_GetCusInfo
end
go
create procedure CCIVR_GetCusInfo
@ProductSN varchar(50),--主机编号
@CustomerID varchar(50),--客户ID
@CustomerPassword varchar(50),--客户密码
@StationID varchar(50),--服务站ID
@Phone varchar(50),--来电号码
@MethodCode varchar(50),--方法Code
@ServiceFlag varchar(50),--服务属性标签
@CustomerLevel varchar(50), --客户级别
@ResultMsg varchar(200) output--返回信息
as
begin
select ec.CustomerID as CustomerID,c.CustomerID as UserID
from BS_CustomerPhone cp
inner join BS_Contactor c on cp.CustomerID = c.CustomerID
inner join BS_EnterpriseCustomer ec on ec.CustomerID = c.ParentID
where
(cp.FullPhone = SUBSTRING(@Phone,2,11) --Parameter
and substring(cp.Phone,1,3) in ('013','014','015','018'))
or (cp.AreaNo + cp.Phone = @Phone --Parameter
and substring(cp.Phone,1,3) not in ('013','014','015','018'))
end