>I triedn to execute teh following code:
>
>
>DECLARE trabajador_cursor CURSOR
> FOR
> SELECT cod_emple FROM plplfmae WHERE condicion = 'ON'
>OPEN trabajador_cursor
>DECLARE @codigotrabajador varchar
>FETCH NEXT FROM trabajador_cursor INTO @codigotrabajador
>WHILE (@@FETCH_STATUS <> -1)
>BEGIN
>
> EXEC ('PA_calculorem' @param1 = @codigotrabajador)
> FETCH NEXT FROM trabajador_cursor INTO @codigotrabajador
>END
>
>
>DEALLOCATE trabajador_cursor
>
>
>
> and i got the following error message:
>
>Servidor: mensaje 170, nivel 15, estado 1, línea 10
>Línea 10: sintaxis incorrecta cerca de '@param1'.
>
>Anyone can help me to find what i did wrong?
>Thank you
You can use
EXECUTE PA_calculorem @param1 = @codigotrabajador
and make sure to declare your varchar parameter with the proper size.
See also
How to return a value from dynamically executed T-SQL code FAQ #8130 for syntax details.
If it's not broken, fix it until it is.
My Blog