十二月 09 2011
使用備份來做起始化Replication-MS SQL
How to: Initialize a Transactional Subscriber from a Backup (Replication Transact-SQL Programming) – http://msdn.microsoft.com/en-us/library/ms147834%28v=SQL.90%29.aspx
十二月 09 2011
How to: Initialize a Transactional Subscriber from a Backup (Replication Transact-SQL Programming) – http://msdn.microsoft.com/en-us/library/ms147834%28v=SQL.90%29.aspx
五月 06 2011
這個是朋友請我查的資料, 其實邏輯上還蠻容易的, 因為 SQL Server的Transactional Replication是參考table的primary key來進行新增刪除修改的, 若是該table沒有primary key的話, 是沒有辦法加入到publication的article裡的.
資料可以參考這裡:
http://msdn.microsoft.com/en-US/library/ms152559%28v=SQL.90%29.aspx
其中的:
Limitations on Publishing Objects
- The maximum number of articles and columns that can be published differs by publication type. For more information, see the "Replication Objects" section of Maximum Capacity Specifications for SQL Server 2005.
- Stored procedures, views, triggers, and user-defined functions that are defined as WITH ENCRYPTION cannot be published as part of SQL Server replication.
- XML schema collections can be replicated but changes are not replicated after the initial snapshot.
- Tables published for transactional replication must have a primary key. If a table is in a transactional replication publication, you cannot disable any indexes that are associated with primary key columns. These indexes are required by replication. To disable an index, you must first drop the table from the publication.
- Bound defaults created with sp_bindefault (Transact-SQL) are not replicated (bound defaults are deprecated in favor of defaults created with the DEFAULT keyword of ALTER TABLE or CREATE TABLE).
上面紅字部分就是說明這個限制.
二月 27 2009
在使用 Replication 時, 若是使用 Transaction 的方式, 若有要新增 article 到 publication 時, 其實很容易.
基本上就只要在原來的 publication 的 property 裡的 articles, 多加上需要 replication 出來的article, 完成後, 他不會自動進行後續, 接下來的動作就是做 snapshot 就行了, 這裡比較討厭的是若是原來的publication資料多, 而加入的 article資料少, 其實很不划算, 不過做完 snapshot 後, replication 機制會開始將該新發行的article schema傳給 subscriber, 讓 subscriber 將沒有的資料寫入, 這樣就完成了.
其實只會做新的部分, 不過因為還是要一個 schema及起始資料, 所以還是得做一個 snapshot 是比較吃資源的地方, 和 alter table的狀況又不太一樣了. 不過操作上還是很直覺也很方便!
參考SQL Server 2005 help 資料: http://msdn.microsoft.com/en-us/library/ms152493(SQL.90).aspx
其中比較重要的是這段:
After adding an article to a publication, you must create a new snapshot for the publication (and all partitions if it is a merge publication with parameterized filters). The Distribution Agent or Merge Agent then copies the schema and data for the new article to the Subscriber (it does not reinitialize the entire publication).
也就是說, 新增完了之後, 要做一次 snapshopt, 不過 agent 會將新的 article 送到 subscriber, 而不會整個 reinitialize!
九月 23 2008
若是SQL Server已設定完成Replication的Article時, 進行資料表異動, 其實會透過 DDL 傳送的方式, 將異動的指令也透過複寫的方式送出, 並進行同步. 可以參考相關文章: http://www.replicationanswers.com/AlterSchema2005.asp
不過若是異動的欄位是 Primary Key時, 將會觸發 exception, 發出如下的訊息:
Msg 4929, Level 16, State 1, Line 2
Cannot alter the table ‘tbltest’ because it is being published for replication.
如此一來便無法使用這種 ddl 傳遞的方式將 Replicated Table 的異動送出. 若是要執行這樣的異動需求, 得先解除掉發行及訂閱此 table, 才能進行調整, 調整完成後才能再重新設定回發行及訂閱, 接下來再做 snap shot 進行遞送出去.
八月 24 2007
在使用 SQL Server Replication 發行資料時, 有個重要的參數必須要特別注意的地方, 就是 max text repl size, (在 SQL 2005也會影響 varchar(MAX) 這種型態的欄位).
參考這篇 最大文字覆寫大小選項 的設定方法來進行調整(利用 sp_configure).
另外在這篇 交易式複寫考量 也有說明在使用 Replication 時, 要注意覆寫資料的 size 上限, 若是在寫入資料大於該設定的 size 時, 將會發生 error, 內容如下:
Length of LOB data (??????) to be replicated exceeds configured maximum 65536
如此一來便會造成寫入失敗而無法成功寫入資料, 這在沒有使用 交易式複寫 時不會發生的問題. 這在使用交易式複寫時要特別注意的地方!
八月 10 2007
在使用 SQL Server Replication 機制時, 要特別注意有關複寫參數的部分, 由於預設是不會複製 noclustered indexes的, 所以在使用上要特別注意這點. 這樣的預設有好有壞, 好處是複寫出來到訂閱者資料庫的彈性相當大, 可以依需要再進行 index 設計及應用, 壞處是若管理人員或使用人員沒有發現, 在使用上將會有某種影響訂閱者資料庫的效能!