Microsoft KB Archive/918039

= Error message when you use the correct syntax of the CREATE TYPE statement in SQL Server 2005: &quot;Incorrect syntax near 'ObjectName'&quot; =

Article ID: 918039

Article Last Modified on 5/9/2006

-

APPLIES TO


 * Microsoft SQL Server 2005 Standard Edition
 * Microsoft SQL Server 2005 Developer Edition
 * Microsoft SQL Server 2005 Enterprise Edition
 * Microsoft SQL Server 2005 Express Edition
 * Microsoft SQL Server 2005 Workgroup Edition

-



Bug #: 404124 (SQLBUDT)



SYMPTOMS
Consider the following scenario. In Microsoft SQL Server 2005, you use the correct syntax of the CREATE TYPE statement to create a common language runtime (CLR) user-defined type in a database. The compatibility level of the database is set to 80. In this scenario, you receive the following error message:

Server: Msg 102, Level 15, State 1, Line 2

Incorrect syntax near ' '.

However, you receive the expected error message if you do the following:
 * You use the CREATE PROCEDURE statement or the CREATE FUNCTION statement.
 * You create a CLR stored procedure or a CLR function.

The error message contains the following text:

Server: Msg 325, Level 15, State 1, Procedure, Line 4 Incorrect syntax near 'external'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel.



RESOLUTION
To resolve this problem, you must set the compatibility level of the database to 90 when you try to create CLR objects on the database. To do this, run the following statement for the database:

exec sp_dbcmptlevel ' ', 90

Note If you migrate a database from Microsoft SQL Server 2000 to SQL Server 2005, you must make sure that you set the compatibility level to 90 before you create a CLR object in the database.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Keywords: kbtshoot kbprb kbexpertiseadvanced kbsql2005clr KB918039

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.