i try to do this but i can't do it, help please:
Send the name of a table as a variable to a stored procedure to make a select query whit that variable. Example:
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)
 
     
     
    