-1

I have one procedure

Create procedure [dbo].[daily_stats]
@date datetime, @grouping varchar(150)
as

select callid,campaignid,dnis,anidigits,callstarttime,totalcalltime,agenttalktime,agentid,abandon,queuewaittime,calltype,call_acw,datestamp,bill_flag,
queueid,queuename,calldelayed, callholdtime, shortcall,ctr_name,role_name,team_name,callhold_times,agent_fullname,xferto,timeafterxfer,
obcallids,obcalls,obtime,orgname, getdate() as ImportedDate

into #tempid7

from openquery(orapr2, 'select * from sp_calldetail
where trunc(callstarttime) >= trunc(sysdate-1) and abandon in (0,1) and (upper(campaignid) in (''SYNAPSE'', ''SYNAPSECALLBACK'') or campaignid like ''ME%'')')

I want to pass @date value at trunc(sysdate-1). How do I do that?

Mat
  • 202,337
  • 40
  • 393
  • 406

2 Answers2

0

how to pass date parameter in openquery statement

Instead of using openquery function you could try this solution

EXEC LINKEDSVR_BUH_03.TestUPSERT.dbo.Customer_Select @pCustomerID = 2
EXEC LINKEDSVR_BUH_03..dbo.Customer_Select @pCustomerID = 2 -- It uses default database (see Catalog property for linked server)

or this

EXEC (N'TestUPSERT.dbo.Customer_Select ?', 2) AT LINKEDSVR_BUH_03
EXEC (N'dbo.Customer_Select ?', 2) AT LINKEDSVR_BUH_03 -- It uses default database (see Catalog property for linked server)
                            ^----- parameter placeholder
                                ^----- parameter value
Bogdan Sahlean
  • 19,233
  • 3
  • 42
  • 57
0

I found I had to convert the date-time to Oracle format - for example :

TO_DATE(''''' + CONVERT(varchar(10), @From, 120) + ''''',''''YYYY-MM-DD'''')

Otherwise it returned the error - Invalid Month

Benno
  • 2,534
  • 1
  • 17
  • 27