Error 170

Severity Level 15

Message Text

Line%d: Incorrect syntax near '%.*s'.

Explanation

This error occurs when a function has been entered as part of the EXECUTE statement.

For example, this procedure will produce error 170:

declare @myint int
select @myint = 5
exec ("select "+str(@myint))

Action

Construct the full string before passing it to the EXECUTE statement. The batch in the above example can be changed to the following which works correctly:

declare @mycmd char(50)
declare @myint int
select @myint=5
select @mycmd="select "+str(@myint)
exec (@mycmd)