日期:2014-05-16 浏览次数:20564 次
declare @tsql varchar(600)
select @tsql='select distinct rsi_doctorcode from rsi_sampleinfo_yezi where 1=1 '
+case when @areacode<>'' then ' and rsi_area='''+@areacode+'' else '' end
+case when @hospitalname<>'' then ' and hospitalname=''%'+@hospitalname+'%' else '' end
+case when @doctorname<>'' then ' and doctorname=''%'+@doctorname+'%' else '' end
+case when @proxyname<>'' then ' and proxyname=''%'+@proxyname+'%' else '' end
+case when @proxyphone<>'' then ' and proxyphone=''%'+@proxyphone+'%' else '' end
+case when @proxyemail<>'' then ' and proxyemail=''%'+@proxyemail+'%' else '' end
declare @tsql varchar(600),@areacode VARCHAR(50), @hospitalname VARCHAR(50),@doctorname VARCHAR(50),@proxyname VARCHAR(50),
@proxyphone VARCHAR(50),@proxyemail VARCHAR(50)
SELECT @tsql='select distinct rsi_doctorcode from rsi_sampleinfo_yezi where 1=1 '
IF @areacode>''
SET @tsql=@tsql+' and rsi_area=@areacode'
IF @hospitalname>''
SET @tsql=@tsql+' and hospitalname=@hospitalname'
...--中间的自己去写
EXEC sp_executesql @tSql
,N'@areacode VARCHAR(50), @hospitalname VARCHAR(50),@doctorname VARCHAR(50),@proxyname VARCHAR(50),@proxyphone VARCHAR(50),@proxyemail VARCHAR(50)'
,@areacode , @hospitalname ,@doctorname ,@proxyname ,@proxyphone ,@proxyemail
SELECT DISTINCT
b.rsi_areaname ,
b.rsi_region ,
a.wp_ACNid ,
b.rsi_hospital AS rsi_shopname ,
b.rsi_doctorcode ,
b.rsi_doctor ,
b.rsi_proxycode ,
b.rsi_proxy ,
b.rsi_proxy_phone