FIX: "Incorrect syntax near" error when you use a "datetimeoffset" type column as the partitioning column in SQL Server 2008 R2

Article translations Article translations
Article ID: 2791626 - View products that this article applies to.
Microsoft distributes Microsoft SQL Server 2008 R2 Service Pack 2 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 R2 Service Pack 2 fix release.
Expand all | Collapse all

On This Page

Symptoms

Consider the following scenario:
  • You have a partitioned table that uses a datetimeoffset type column as a partitioning column in Microsoft SQL Server 2008 R2.
  • You use the New Publication Wizard to create a snapshot publication of the partitioned table in SQL Server Management Studio (SSMS).
In this scenario, you receive the following error message in one of the scripts that is used to create the snapshot publication. The scripts are automatically generated by the New Publication Wizard.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ''.

Note For a detailed example scenario in which this issue would occur, refer to the "More Information" section.

Resolution

Cumulative update information

Cumulative Update 5 for SQL Server 2008 R2 SP2

The fix for this issue was first released in Cumulative Update 5. For more information about how to obtain this cumulative update package for SQL Server 2008 R2 SP 2, click the following article number to view the article in the Microsoft Knowledge Base:
2797460 Cumulative update package 5 for SQL Server 2008 R2 Service Pack 2
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 R2 SP 2 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
2730301 The SQL Server 2008 R2 builds that were released after SQL Server 2008 R2 Service Pack 2 was released

More information

Assume that you create a partition function in SQL Server 2008 R2, and that the data type of input_parameter_type is datetimeoffset. Then you use Script Partition Function as in SSMS. In this scenario, the issue that is described in the "Symptoms" section occurs. Additionally, the date-literal range values generated by SSMS are not quoted in single quotation marks.

For example, you execute the following statement to create a partition function:
CREATE PARTITION FUNCTION PF_TEST (datetimeoffset(7)) as range right for values('20100101', '20100201', '20100301')
Then, you right-click the partition function in the Object Explorer, select Script Partition Function as, select Create To, and then select New Query Editor Window in SSMS. You see the following generated script:
CREATE PARTITION FUNCTION [PF_TEST] (datetimeoffset(7)) AS RANGE RIGHT FOR VALUES (1/1/2010 12:00:00 AM +00:00, 2/1/2010 12:00:00 AM +00:00, 3/1/2010 12:00:00 AM +00:00)

If you try to run the generated script, then you receive the following error message:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '12'.

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Properties

Article ID: 2791626 - Last Review: February 18, 2013 - Revision: 1.0
Applies to
  • Microsoft SQL Server 2008 R2 Service Pack 2
  • Microsoft SQL Server 2008 R2 Datacenter
  • Microsoft SQL Server 2008 R2 Enterprise
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Standard
  • Microsoft SQL Server 2008 R2 Workgroup
Keywords: 
kbqfe kbfix kbsurveynew kbexpertiseadvanced KB2791626

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com