Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9017311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:14:24+00:00 2026-06-16T04:14:24+00:00

im using sql server 2012 and transactional replication in it. im trying to replicate

  • 0

im using sql server 2012 and transactional replication in it. im trying to replicate a view which has a specific database role attached in the permissions. this is my replications script for the view

: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

after replicating, the view is getting created but the role is not getting attached to permissions of the view. this role is present in both publisher and subscriber databases. and this roles is assigned to the table used in the view and the table exists on both the databases.

i tried setting the schema_option to 0x48000001 which is

  1. Generates the object creation script (CREATE TABLE, CREATE PROCEDURE, and so on). This value is the default for stored procedure articles.
  2. Create any schemas not already present on the subscriber.
  3. Replicate permissions.

i have also gone through this post, http://social.msdn.microsoft.com/Forums/en-US/sqlreplication/thread/a4fa2d32-00ea-47a7-9276-52764fab72ae/ which says above schema_option value should work. or we have to use @post_snapshot_script in sp_addpublication.

i tried with @post_snapshot_script and it is working, but i dont want to use this approach.

please let me know how to solve this problem.

thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:14:26+00:00Added an answer on June 16, 2026 at 4:14 am

    This is a known issue in SQL Server 2012. This issue happens because of a bug in the snapshot agent. There is a work around for now till Microsoft release a fix for this issue:
    1. Open the snapshot folder.
    2. Edit the .sch file for your view by adding the required permissions.

    Subscribers can get the correct snapshot after that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQL Server 2012 and trying to implement transactional replication. Im using the
Im using sql server 2012 and its replication feature. Here im trying to manually
Im using sql server 2012 and transactional replication. For replication security, I created a
Using SQL Server 2012 Express. I have a table which represents key/value pairs. keycol
im using sql server 2012 and replication process in it. now the replication process
I'm using SQL Server 2008 R2 and I have a database which contains two
I am using a JDBC driver for Microsoft SQL Server 2012 (sqljdbc_4.0) and although
We have an issue upgrading to SQL Server 2012. I am using the following
Using SQL Server 2008. I have multiple Locations which each contain multiple Departments which
I'm using SQL Server 2012 and I'm stuck with a strange problem. I tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.