Have you trying to script tables in your SQL2005 or 2008 database and you receive this error?

Column projectDescription in object [TABLENAME] contains type NVarCharMax, which is not supported in the target server version, SQL Server 2000. (Microsoft.SqlServer.Smo)

This error is caused by an incorrect scripting option in Microsoft SQL Server Management Studio being set to a version prior to 2005.

Obviously, to use the nVarCharMax field type the compatibility mode on the database needs to be 90 or 100, which is SQL 2005 and 2008.  You can easily check this via script (like below) or the Properties > Options screen on the database properties.

SELECT compatibility_level from sys.databases WHERE name='[MYDATABASE]' 

To correct the error caused by the table creation; using Microsoft SQL Server Management Studio, go to TOOLS menu, then OPTIONS.  Expand “SQL Server Object Explorer”, then select “Scripting”.  You should see a screen like the example below (SQL2008).  Simply update the “Script for server version” to the appropriate setting, then try scripting your table again.

One thought on “Having Trouble Scripting SQL Tables Containing nvarchar(max) fields

Leave a Reply

Your email address will not be published. Required fields are marked *