Freigeben über


Replication: Partitioned snapshot fails with "Incorrect syntax near" message when article name has more than 40 characters

Repro:

** note: if you will be trying this repro – please remember to alter the script to suit your environment (Example: @web_synchronization_url) **

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_Thisisareallylongtablenametoemphisetheissue](
[Col] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [DF__tbl_Activ__Activ__084B3915] DEFAULT (newsequentialid()),
[Col2] [uniqueidentifier] NOT NULL,
[Col3] [uniqueidentifier] NOT NULL,
[Col4] [uniqueidentifier] NOT NULL,
[Col5] [smallint] NOT NULL,
[Col6] [uniqueidentifier] NULL,
[Col7] [nvarchar](20) NOT NULL,
[Col8] [smalldatetime] NOT NULL,
[Dummy] [varchar](50) NULL,
CONSTRAINT [tbl_Thisisareallylongtablenametoemphisetheissue_PK] PRIMARY KEY CLUSTERED
(
[Col] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

-- Enabling the replication database
use master
exec sp_replicationdboption @dbname = N'SQLCORNERSTEST', @optname = N'merge publish', @value = N'true'
GO

-- Adding the merge publication

use [SQLCORNERSTEST]
exec sp_addmergepublication @publication = N'SQLSCORNER_NODATAPublication', @description = N'Merge publication of database ''SERVERNAME'' from Publisher ''SERVERNAME''.', @sync_mode = N'native', @retention = 14, @allow_push = N'true', @allow_pull = N'true', @allow_anonymous = N'true', @enabled_for_internet = N'false', @snapshot_in_defaultfolder = N'false', @alt_snapshot_folder = N'\\SQLSCORNER\SQLSnapshot', @compress_snapshot = N'true', @ftp_port = 21, @ftp_login = N'anonymous', @allow_subscription_copy = N'false', @add_to_active_directory = N'false', @dynamic_filters = N'true', @conflict_retention = 14, @keep_partition_changes = N'true', @allow_synctoalternate = N'false', @validate_subscriber_info = N'HOST_NAME()', @max_concurrent_merge = 0, @max_concurrent_dynamic_snapshots = 0, @use_partition_groups = N'true', @publication_compatibility_level = N'90RTM', @replicate_ddl = 1, @allow_subscriber_initiated_snapshot = N'false', @allow_web_synchronization = N'true', @web_synchronization_url = N'https://SERVERNAME/SQLSCORNER/replisapi.dll', @allow_partition_realignment = N'true', @retention_period_unit = N'days', @conflict_logging = N'both', @automatic_reinitialization_policy = 1
GO

exec sp_addpublication_snapshot @publication = N'SQLSCORNER_NODATAPublication, @frequency_type = 4, @frequency_interval = 14, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 1, @frequency_subday_interval = 5, @active_start_time_of_day = 500, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = null, @job_password = null, @publisher_security_mode = 1
go
exec sp_grant_publication_access @publication = N'SQLSCORNER_NODATAPublication', @login = N'sa'
GO
exec sp_grant_publication_access @publication = N'SQLSCORNER_NODATAPublication', @login = N'NT AUTHORITY\SYSTEM'
GO
exec sp_grant_publication_access @publication = N'SQLSCORNER_NODATAPublication', @login = N'BUILTIN\Administrators'
GO
exec sp_grant_publication_access @publication = N'SQLSCORNER_NODATAPublication', @login = N'distributor_admin'
GO

-- Adding the merge articles

use [SQLCORNERSTEST]
exec sp_addmergearticle @publication = N'SQLSCORNER_NODATAPublication'', @article = N'tbl_Thisisareallylongtablenametoemphisetheissue', @source_owner = N'dbo', @source_object = N'tbl_Thisisareallylongtablenametoemphisetheissue', @type = N'table', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000C034FD1, @identityrangemanagementoption = N'none', @destination_owner = N'dbo', @force_invalidate_snapshot = 1, @force_reinit_subscription = 0, @column_tracking = N'false', @subset_filterclause = N'CreatedBy=HOST_NAME()', @vertical_partition = N'false', @verify_resolver_signature = 1, @allow_interactive_resolver = N'false', @fast_multicol_updateproc = N'true', @check_permissions = 0, @subscriber_upload_options = 0, @delete_tracking = N'true', @compensate_for_errors = N'false', @stream_blob_columns = N'false', @partition_options = 0
GO

Error received while generating snapshot: Incorrect Syntax near “”

Solution:

When article name has more than 40 characters, the snapshot fails with message "Incorrect syntax near" the word that is close to this changes depending on the length of the article name.

The solution is to shorten the article name