| Author |
Topic |
|
ramu143
Yak Posting Veteran
64 Posts |
Posted - 2008-11-01 : 01:54:34
|
| previously i am using this quirey in SP' insert into '+@tb2+' select yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,0 isCallback, cast(callcost as decimal (10,5)) cost,count(*) attempt, sum(case when connectflg=1 then 1 else 0 end) connected,sum(talktime) Talktime from '+@tb1+' where talktime >0 and where trunk is null group by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) order by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) ' NOW I AM using BELOW one.' insert into '+@tb2+' select yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,0 isCallback, cast(callcost as decimal (10,5)) cost,count(*) attempt, sum(case when connectflg=1 then 1 else 0 end) connected,sum(talktime) Talktime from '+@tb1+' where talktime >0 and where trunk is null or trunkin =’bridge’ group by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) order by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) 'now i am geeting errore in where talktime >0 and where trunk is null or trunkin =’bridge’ heare please solve this how can we use this one in SpERRORE IS Incorrect syntax near the keyword 'where'. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-01 : 02:05:11
|
quote: Originally posted by ramu143 previously i am using this quirey in SP' insert into '+@tb2+' select yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,0 isCallback, cast(callcost as decimal (10,5)) cost,count(*) attempt, sum(case when connectflg=1 then 1 else 0 end) connected,sum(talktime) Talktime from '+@tb1+' where talktime >0 and where trunk is null group by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) order by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) ' NOW I AM using BELOW one.' insert into '+@tb2+' select yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,0 isCallback, cast(callcost as decimal (10,5)) cost,count(*) attempt, sum(case when connectflg=1 then 1 else 0 end) connected,sum(talktime) Talktime from '+@tb1+' where talktime >0 and where trunk is null or trunkin =’bridge’ group by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) order by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) 'now i am geeting errore in where talktime >0 and where trunk is null or trunkin =’bridge’ heare please solve this how can we use this one in SpERRORE IS Incorrect syntax near the keyword 'where'.
you need to use only a single where. remove the second where |
 |
|
|
ramu143
Yak Posting Veteran
64 Posts |
Posted - 2008-11-01 : 03:18:36
|
| Incorrect syntax near '’'.after chnging i am getting the above errore vishka can u please help me |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-01 : 03:25:21
|
modifylike this and see' insert into '+@tb2+' select yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,0 isCallback, cast(callcost as decimal (10,5)) cost,count(*) attempt, sum(case when connectflg=1 then 1 else 0 end) connected,sum(talktime) Talktime from '+@tb1+' where talktime >0 and trunk is null or trunkin =''bridge'' group by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) order by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) ' |
 |
|
|
ramu143
Yak Posting Veteran
64 Posts |
Posted - 2008-11-01 : 03:37:06
|
| Server: Msg 207, Level 16, State 3, Line 2Invalid column name 'trunk'.Server: Msg 207, Level 16, State 1, Line 2Invalid column name 'bridge'.Server: Msg 207, Level 16, State 1, Line 2Invalid column name 'trunk'.Server: Msg 207, Level 16, State 1, Line 2Invalid column name 'bridge'.Server: Msg 207, Level 16, State 1, Line 2Invalid column name 'trunk'.Server: Msg 207, Level 16, State 1, Line 2Invalid column name 'bridge'.these are the erore i am gettingmy require ment is you are taking the values like ‘where trunk is null ’, now you have to change it to where trunk is null or trunkin =’bridge’ . |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-01 : 07:00:13
|
| do you have a column called trunk in your table? also ca you post your full query? |
 |
|
|
ramu143
Yak Posting Veteran
64 Posts |
Posted - 2008-11-02 : 00:47:26
|
| sure vishka i will post you tomarrow please help me on this one |
 |
|
|
ramu143
Yak Posting Veteran
64 Posts |
Posted - 2008-11-02 : 23:01:57
|
| ALTER procedure ostat_CDS_rpt47_2006 @pYear int, @pMonth int, @pDay1 int, @pDay2 int as begin declare @sql varchar(4000) declare @tb1 varchar(128) declare @tb2 varchar(128) --select top 10 * from margin..ncds_missing_jun08 --select * into ob_mar08_bckup from ob_mar08 set @tb1= 'RPTMAIN.month10.dbo.lycacds1023' set @tb2='Report.dbo.ob_OCT08' set @sql= ' insert into '+@tb2+' select yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,0 isCallback, cast(callcost as decimal (10,5)) cost,count(*) attempt, sum(case when connectflg=1 then 1 else 0 end) connected,sum(talktime) Talktime from '+@tb1+' where talktime >0 and trunk is null or trunkin = 'bridge' group by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) order by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) ' --print (@sql) exec (@sql) end |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-02 : 23:26:17
|
the below works fine for mealter procedure ostat_CDS_rpt47_2006 @pYear int, @pMonth int, @pDay1 int, @pDay2 intas begin declare @sql varchar(4000) declare @tb1 varchar(128) declare @tb2 varchar(128) --select top 10 * from margin..ncds_missing_jun08 --select * into ob_mar08_bckup from ob_mar08 set @tb1= 'RPTMAIN.month10.dbo.lycacds1023' set @tb2='Report.dbo.ob_OCT08' set @sql= ' insert into '+@tb2+' select yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,0 as isCallback, cast(callcost as decimal (10,5)) as cost,count(*) as attempt, sum(case when connectflg=1 then 1 else 0 end) as connected,sum(talktime) as Talktime from '+@tb1+' where talktime >0 and trunk is null or trunkin = ''bridge'' group by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) order by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5)) ' --print (@sql) exec (@sql) end |
 |
|
|
|
|
|