Write Access denied after replicating DB in Microsoft SQL Server 2012

I set up Replication in MS SQL Server 2012 Standard edition by using the standard create distributor, create publisher, new publication, new subscriber method in MSSMS. Before I added a DB to be published, it was accessible by my application. As soon as I publish the DB for Replication (Merge), my application says 'write access denied'. I'm using the same username to connect to the DB, nothing really changed other than marking the DB for publication.

What can I do to enable Read/Write access to this DB after publication? I cannot for the life of me figure out what combination of permissions I need, etc. I've tried connecting as a SQL user (sa) with full permissions plus many other things. The DB properties say False when checking the Read Only status.

Any help is greatly appreciated!

Thanks,

Chris
metricroofingAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
metricroofingConnect With a Mentor Author Commented:
This ended up being an application restriction, not a problem with MSSQL Replication.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Did you check if a snapshot was running in the meanwhile?
Also, it's an application error and that can be very generic message error. Did you check for errors in SQL Server log?
0
 
metricroofingAuthor Commented:
Thanks for your reply.  It's a small test DB and the snapshot finished very quickly. Also, I checked the SQL server log and there are no errors when making the connection to the DB. I checked both my local event log and the server's event log for Security events that might be indicative of what's happening. Strange thing is, the login events are the same as when the DB is not replicated (same UN, etc). I spoke wiht my applications support team and they referenced the Locking table and advised me to clear that and it should be read/write but there was no data in the locking table.

The only thing I can see different is the addition of the rowguid column to the DB tables. I'm not sure why that could be preventing write access though.

Thanks!
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Yes, sounds like a lock issue. During the Snapshot locks may occur but since you said that finished very quickly then should be something else that originates the locks.
You can run a SQL Profiler to audit what's happening in the database. You may find some interesting things with a trace.
Can't think in another solution by now.
0
 
metricroofingAuthor Commented:
Ok, so a SQL profiler, should I run that while assigning the DB as a publication or just during my attempts to connect to the DB after I've assigned it as a publication? Thanks!
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
I would say that you'll only need to run in during the attempts to connect since it's when the error occurs.
0
 
metricroofingAuthor Commented:
OK, I have run the SQL Trace on my connection to the DB. I have found out some interesting things. Hopefully you can help with these new findings?

So, the trace identified an attempt to write to the locking table but appears to not actually write to it. I then, disabled publication of the DB and ran a trace then. I show the table being written to and then the row being deleted which seems to indicate a successful write. Now, I have narrowed this problem down to the addition of the rowguid coumn in this or all of the tables. When I view the INSERT statement via SQL trace, I'm showing that the statement does not include defined column names. Upon reading the Merge replication details, it says that INSERT statements will fail if column defs are not included in INSERT statements. So, I believe that's my problem.

The developer will most likely not adjust their code for us to include column defs in all their insert statements. Is there any way I can adjust the tables or DB to somehow make this happen myself?? As far as I can tell stored procedures are not used.

Thank you!
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
I'm still wondering why it locks the table if the replication is running. Could you understand why it's having these behavior?
0
 
metricroofingAuthor Commented:
I don't think it's so much locking the table against replication. The replication part works fine. I was able to create a subscriber and the whole DB replicated via the snapshot and I can access it. It's just when the application tries to access to the DB that I get "read only".  I spoke with the application dev and they said the Locking table is the first to be test written to when connecting the the DB. It's supposed to ensure no one else is connecting at the very same moment or something like that. Like I said above, after running a Trace, I found the application does not provide column definitions in it's INSERT statements. Replication is said to fail if column defs are not included. I'm just wondering if there's a way I can manipulate the DB tables or similar to avoid this issue while still getting replication.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
I found the application does not provide column definitions in it's INSERT statements.
Yeah, this isn't a good thing to do.

I'm just wondering if there's a way I can manipulate the DB tables or similar to avoid this issue while still getting replication.
Without changing the application? I don't think so.
0
 
metricroofingAuthor Commented:
Application was limited in it's SQL coding, did not pass coumn headers with select statements thus rendering itself in compatible with the newly created column that replication installs.
0
All Courses

From novice to tech pro — start learning today.