>Normally, SQL Server doesn't let you parameterize the FROM clause of a query. I've not seen anything that says that the behavior changes within a CURSOR and I've not explicitly tried it either. If SQL Server is complaining about it, then it probably doesn't work.
The parser was complaining about @NomTable.
I have changed my declaration to :
EXEC(' DECLARE ms_crs_1 CURSOR GLOBAL static FOR
SELECT Annee, Mois, ' + @NomChamp + ',
' + @NomChamp + 'Cum ' + ',
' + @NomChamp + 'Ann ' + ',
' + @NomChamp + 'Annuel' + '
FROM ' + @NomTable + '
WHERE ' + @NomChamp + ' <> 0
ORDER BY Annee, Mois')
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com