Error 170

Troubleshooting SQL Server

Troubleshooting

Error 170

Severity Level 15
Message Text

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

Explanation

This error indicates that the syntax of a Transact-SQL statement is incorrect and that the syntax error was detected near the Transact-SQL syntax element specified in the error message. The most frequent causes for syntax errors are misspellings of Transact-SQL syntax elements or operators, and specifying the syntax of a Transact-SQL statement in the wrong order.

This example produces error 170:

USE Northwind
GO
SELECT &
FROM Categories
ORDER BY CategoryName ASC
Action

First, check the Transact-SQL statement syntax near the syntax element specified in the error message. Because Transact-SQL language syntax can be very complex, Microsoft® SQL Server™ may report the syntax error later in the Transact-SQL statement syntax than it actually occurred. Second, reexamine the entire Transact-SQL statement that generated the error. Verify the syntax order of the statement.

In the above example, changing the ampersand (&) to an asterisk (*) corrects the problem:

USE Northwind
GO
SELECT *
FROM Categories
ORDER BY CategoryName ASC

See Also

Errors 1 - 999

Transact-SQL Overview