0
I’m making this mistake:
Incorrect syntax next to@SQL_LINKED.. Error 102. SQLSTATE 42000. Severity 15. Msgstate 1. Line 78.
When trying to run this script :
SET @SQL_LINKED = 'SELECT CAST(v.produto AS VARCHAR(20)) AS CAIXA,
v.formula AS FORMULA,
coalesce(v.COMP_B,0) AS CHB01,
coalesce(v.COMP_C,0) AS CHC01,
coalesce(v.COMP_BC,0) AS CHBC01,
coalesce(v.COMP_E,0) AS CHE01,
coalesce(v.COMP_BB,0) AS CHBB01,
coalesce(v.COMP_BE,0) AS CHBE01,
coalesce(v.COMP_AC,0) AS CHAC01,
coalesce(v.COMP_EC,0) AS CHEC01,
coalesce(v.COMP_A,0) AS CHA01,
coalesce(v.COMP_D,0) AS CHD01,
coalesce(v.COMP_DC,0) AS CHDC01
FROM produtos_calc_l v
WHERE v.produto = '''''+@CodCai+'''''
AND v.formula NOT LIKE ''%D%'''
INSERT INTO ##tempvincos (codref, C, A, B,D, caixa, formula, chb01, chc01,
chbc01, che01, chbb01, chbe01, chac01, chec01, cha01, chd01, chdc01 )
SELECT @CODREF, @ALTURA, @COMPRIM, @LARGURA, 0, Vinco.* FROM (SELECT
* FROM Openquery("server", @SQL_LINKED) ) AS Vinco
How should I pass the @SQL_LINKED to the Openquery ?
How is the @Codcai variable declared? // How is the v.product column declared?
– José Diz
Is stated as
Declare @codcai varchar(20)
.– Aprendiz
And how the column is declared
v.produto
?– José Diz