PDA

View Full Version : خطای این کوئری کجاست؟



ly.comeng
سه شنبه 11 آبان 1395, 10:01 صبح
سلام دوستان لطفا این کوئری رو ببینید:

*****************************/
alter procedure [dbo].[sp_test]
@FromDate datetime,
@ToDate datetime,
@CentersStr nvarchar(max),
@TypesStr nvarchar(max),
@IranCitysStr nvarchar(max)
as
begin
declare @String nvarchar(max)=''
set @String='
declare @typeTable GenericintIDListType;
insert into @typeTable select * from ConvStringTointIDTable ('''+@TypesStr+''')
declare @Dnat table (caller bigint,Region nvarchar(max),CallCount bigint,Duration bigint,Pulse bigint,Price bigint);
insert into @dnat
select * from openquery(Aux1,''
set transaction isolation level read uncommitted;
with cte as
(
select caller, Region,count(*) as CallCount,sum(convert(bigint,Duration))/60 as Duration ,sum(convert(bigint,pulse)) as Pulse ,sum(Price)as Price
from med.mapzones
inner join IranCities on IranCities.ID=MapZones._IranCityID
inner join hot.dbo.Dnat on dnat._MapZoneID = mapzones.id
where Dnat.calltime between '''''+convert(nvarchar,@FromDate)+''''' and '''''+convert(nvarchar,@ToDate)+'''''
'+case when @IranCitysStr<>'' then 'and _IranCityID in ('+@IranCitysStr+')' else '' end+'
'+case when @CentersStr<>'' then 'and dnat._CenterID in (select ID from Centers)' else '' end+'
and dnat._SourceTypeID in (1,11)
group by Region,caller
)
select * from cte;
'');
declare @SumPrice money,@SumPulse money,@tedad bigint
set @SumPrice = (select Sum(Price) from @Dnat)
set @SumPulse = (select Sum(Pulse) from @Dnat)
set @tedad = (select distinct caller from @Dnat)
select Convert(money,(Pulse/@SumPulse)*100) as PulsePercent,(price/@SumPrice)*100 as PricePercent,@tedad from @Dnat;
';
--exec sp_dumpQuery @String;
exec(@String);
end
[/SQL]

بعد از اجرا این خطا رو میده :
Procedure or function sp_getInterConnectionReporttest has too many arguments specified.

ممنون میشم راهنمایی کنید نمیدونم کجارو اشتباه نوشتم!

gerdioz
سه شنبه 11 آبان 1395, 10:13 صبح
یکی از خطاهاش
تو این خطه
set @String'
شما یک کالن باز کردی و لی نبستی

khorsandreza
چهارشنبه 12 آبان 1395, 00:31 صبح
سلام
نمیدانم مشکل را حل کردی یا نه ؟ ولی چرا اینقدز شلوغ نوشتی حداقل بلوک ، بلوک بنویس تست کن در اخر همه بلوک ها را ادغام کن . اینطور کسی نمی تونه تست کنه .
بیشتر بنظر می اید خطا از این سطر به بعد اتفاق می فته

where Dnat.calltime between '''''+convert(nvarchar,@FromDate)+''''' and '''''+convert(nvarchar,@ToDate)