即時通訊使用SQL Server 2012及其中的事務複製。即時通訊嘗試複製在權限中附加了特定數據庫角色的視圖。這是我複製腳本視圖對視圖的權限沒有得到複製
:setvar SubscriberDB "ReplicationSubscriberDB"
:setvar SubscriberServerName "HYDHTC0131320D\MSSQLSERVER2"
:setvar PublisherDB "PublisherDB"
:setvar PublisherServerName "HYDHTC0131320D"
:setvar ReplicationAccount "myusername"
:setvar ReplicationAccountPassword "mypassword"
GO
:on error exit
GO
exec sp_addpublication @publication = N'DepartmentsView', @description = N'Transactional publication of database from Publisher ''$(PublisherServerName)''.', @sync_method = N'concurrent', @retention = 0, @allow_push = N'true', @allow_pull = N'true', @allow_anonymous = N'false', @enabled_for_internet = N'false', @snapshot_in_defaultfolder = N'true', @compress_snapshot = N'false', @allow_subscription_copy = N'false', @add_to_active_directory = N'false', @repl_freq = N'continuous', @status = N'active', @independent_agent = N'true', @immediate_sync = N'true', @allow_sync_tran = N'false', @autogen_sync_procs = N'false', @allow_queued_tran = N'false', @allow_dts = N'false', @replicate_ddl = 1, @allow_initialize_from_backup = N'false', @enabled_for_p2p = N'false', @enabled_for_het_sub = N'false'
GO
exec sp_addpublication_snapshot @publication = N'DepartmentsView', @frequency_type = 1, @frequency_interval = 0, @frequency_relative_interval = 0, @frequency_recurrence_factor = 0, @frequency_subday = 0, @frequency_subday_interval = 0, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = N'$(ReplicationAccount)', @job_password = '$(ReplicationAccountPassword)', @publisher_security_mode = 1
GO
exec sp_addarticle @publication = N'DepartmentsView', @article = N'vwDepartments', @source_owner = N'dbo', @source_object = N'vwDepartments', @type = N'view schema only', @description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x48000001, @destination_table = N'vwDepartments', @destination_owner = N'dbo'
GO
EXEC sp_startpublication_snapshot @publication = N'DepartmentsView'
GO
use [$(PublisherDB)]
GO
exec sp_addsubscription @publication = N'DepartmentsView', @subscriber = N'$(SubscriberServerName)', @destination_db = N'$(SubscriberDB)', @subscription_type = N'Push', @sync_type = N'automatic', @article = N'all', @update_mode = N'read only', @subscriber_type = 0
GO
exec sp_addpushsubscription_agent @publication = N'DepartmentsView', @subscriber = N'$(SubscriberServerName)', @subscriber_db = N'$(SubscriberDB)', @job_login = N'$(ReplicationAccount)', @job_password = '$(ReplicationAccountPassword)', @subscriber_security_mode = 1, @frequency_type = 4, @frequency_interval = 1, @frequency_relative_interval = 0, @frequency_recurrence_factor = 0, @frequency_subday = 8, @frequency_subday_interval = 6, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 20120607, @active_end_date = 99991231, @enabled_for_syncmgr = N'False', @dts_package_location = N'Distributor'
GO
複製之後,是越來越創建視圖,但作用沒有得到連接到視圖的權限。這個角色出現在發佈者和訂閱者數據庫中。並將此角色分配給視圖中使用的表,並且該表存在於兩個數據庫中。
我試過schema_option設置爲0x48000001是
- 生成對象創建腳本(CREATE TABLE,CREATE PROCEDURE,等等)。此值是存儲過程項目的默認值。
- 創建訂戶上尚不存在的任何模式。
- 複製權限。
我也經歷了這個職位,http://social.msdn.microsoft.com/Forums/en-US/sqlreplication/thread/a4fa2d32-00ea-47a7-9276-52764fab72ae/它說上面的schema_option值應該工作。或者我們必須在sp_addpublication中使用@post_snapshot_script。
我試過@post_snapshot_script,它工作,但我不想使用這種方法。
請讓我知道如何解決這個問題。
在此先感謝。
這看起來像在SQL Server 2012中的一個問題。 – Harsha