22,209
社区成员
发帖
与我相关
我的任务
分享
--try:
declare @sqlstr varchar(max), @querywhere varchar(max)
set @querywhere='where s.StoreNo =''234'' '
if charindex(' s.',@querywhere)=0 set @querywhere=@querywhere+' and s.storeno!=s.storeno'
if charindex(' d.',@querywhere)=0 set @querywhere=@querywhere+' and d.DepotNo!=d.DepotNo'
set @sqlstr='
select distinct ''店'' as ttype, s.StoreNo as tNo,s.StoreName as tName,s.Provinces,s.City,s.Region
from ST_Store s,ST_Depot d '+@querywhere+'
union
select distinct ''仓库'' as ttype,d.DepotNo as tNo,d.DepotName as tName,d.Provinces,d.City,d.Region
from ST_Depot d,ST_Store s '+@querywhere
exec(@sqlstr)
declare @sqlstr varchar(max), @querywhere1 varchar(max),@querywhere2 varchar(max)
set @querywhere1='where StoreNo =''234'' '
set @querywhere1='where 1=0'
set @sqlstr='
select distinct ''店'' as ttype, StoreNo as tNo,StoreName as tName,Provinces,City,Region
from ST_Store '+@querywhere1+'
union
select distinct ''仓库'' as ttype,DepotNo as tNo,DepotName as tName,Provinces,City,Region
from ST_Depot '+@querywhere2
exec(@sqlstr)