Hello,
The code below works fine in the Query Analyzer but from a Stored Prodedure I get the following error. Any Ideas?
*******************************
SP error:Line 1: Incorrect syntax near '.'.
-------------------------------
*******************************
Query Analyzer works correct
-------------------------------
declare @strDetail char (30)
declare @strOverview char (30)
set @strDetail = 'company1_detail'
set @strOverview = 'company1_overview'
EXEC ('
SELECT
'+@strDetail+'.id,
'+@strDetail+'.uid,
'+@strOverview+'.identifier as oident,
'+@strDetail+'.identifier,
'+@strDetail+'.demanddate,
'+@strDetail+'.contact_id,
'+@strDetail+'.company_id,
'+@strDetail+'.demandsupplier_id,
'+@strDetail+'.demandcompanyorig_id,
'+@strDetail+'.supplier_quotation_sum
FROM '+@strDetail+'
JOIN '+@strOverview+' ON ('+@strDetail+'.overview_id = '+@strOverview+'.id)
where (status_id = 4) and (workstage = 0)
union
select
common_detail.id,
common_detail.uid,
common_overview.identifier as oident,
common_detail.identifier,
common_detail.demanddate,
common_detail.contact_id,
common_detail.company_id,
common_detail.demandsupplier_id,
common_detail.demandcompanyorig_id,
common_detail.supplier_quotation_sum
from common_detail
JOIN common_overview ON (common_detail.overview_id = common_overview.id)
where (status_id = 4) and (workstage = 0)');
The code below works fine in the Query Analyzer but from a Stored Prodedure I get the following error. Any Ideas?
*******************************
SP error:Line 1: Incorrect syntax near '.'.
-------------------------------
*******************************
Query Analyzer works correct
-------------------------------
declare @strDetail char (30)
declare @strOverview char (30)
set @strDetail = 'company1_detail'
set @strOverview = 'company1_overview'
EXEC ('
SELECT
'+@strDetail+'.id,
'+@strDetail+'.uid,
'+@strOverview+'.identifier as oident,
'+@strDetail+'.identifier,
'+@strDetail+'.demanddate,
'+@strDetail+'.contact_id,
'+@strDetail+'.company_id,
'+@strDetail+'.demandsupplier_id,
'+@strDetail+'.demandcompanyorig_id,
'+@strDetail+'.supplier_quotation_sum
FROM '+@strDetail+'
JOIN '+@strOverview+' ON ('+@strDetail+'.overview_id = '+@strOverview+'.id)
where (status_id = 4) and (workstage = 0)
union
select
common_detail.id,
common_detail.uid,
common_overview.identifier as oident,
common_detail.identifier,
common_detail.demanddate,
common_detail.contact_id,
common_detail.company_id,
common_detail.demandsupplier_id,
common_detail.demandcompanyorig_id,
common_detail.supplier_quotation_sum
from common_detail
JOIN common_overview ON (common_detail.overview_id = common_overview.id)
where (status_id = 4) and (workstage = 0)');