我尝试这样做,但我不能这样做,请帮助:
将表的名称作为变量发送到存储过程,以对该变量进行选择查询。例如:
USE [Andes]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[epesos_ing_log]*/
@Tbl_OC_Llamada VARCHAR(128),-- TABLE's NAME
@Tbl_Est_Llamada VARCHAR(128) ,-- TABLE's NAME
@tbl_Resul_Llamada VARCHAR(128) -- TABLE's NAME
as
select iId,
datepart(year, dFechaHora) as año_periodo,
datepart(MM, dFechaHora) as mes_periodo,
cast(dFechaHora as date) as dFecha,
datepart(HH, dFechaHora) as T_hora,
dFechaHora, dFin,
datediff (second, dFechaHora, dFin) as tiempo,
sNumeroTelefono,
'Emisión Ext' as tipo,
(iAgenteEmisor) as Agente
from @Tbl_OC_Llamada
inner join @Tbl_Est_Llamada
on ELL.id_estado = T.iUltimoEstado
inner join @tbl_Resul_Llamada
on RLL.id_res_llamada = T.iResultadoLlamada
where sDireccion = 's'
and len (sNumeroTelefono) > 4
and desc_estado in ('Hablando','Iniciada')
and iAgenteEmisor in (select cod_ejecutiva
from andes.dbo.BORRADOR_EJECUTIVA)