<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Maria Zakourdaev</title><subtitle type="html">  
                                                       
                              


</subtitle><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/atom.aspx</id><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/default.aspx" /><link rel="self" type="application/atom+xml" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/atom.aspx" /><generator uri="http://communityserver.org" version="2.1.61129.1">Community Server</generator><updated>2012-02-27T18:52:00Z</updated><entry><title>Love your enemies.. it pisses them off.</title><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/12/26/love-your-enemies-it-pisses-them-off.aspx" /><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/12/26/love-your-enemies-it-pisses-them-off.aspx</id><published>2012-12-26T19:27:00Z</published><updated>2012-12-26T19:27:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;There is always a threat from somewhere. Old-style DBAs are standing on the shaky ground.&lt;/p&gt;  &lt;p&gt;5 years ago I remember myself defending the SQL Server against the domineering Oracle DBAs. The arguing was always about “who is better”. The Management Studio was a great weapon against sqlplus. And you could always use a “the DDLs are not a part of the transaction “ thing.&amp;nbsp; Without any Oracle DBAs around I must admit that Oracle is pretty amazing product although it requires a huge deal of tuning.&lt;/p&gt;  &lt;p&gt;Then came an era of NoSQL. It’s not easy to compete against such fast loads, easy scale-up and fast development. The NoSQL solutions support the usecases that do not really fit into the relational model, like graphs or unstructured data. On the other hand, the eventual consistency thing does not fit for everyone, the joins between the entities are hard and there are stability problems with many NoSQL products.&amp;nbsp; Twitter apparently has been trying to move from MySQL to Cassandra for over a year. In August 2011 Foursquare reported an 11-hour downtime because of the MongoDB. &lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;A few years ago a new trend/treat arrived to our lands. Analytical databases. &lt;/p&gt;  &lt;p&gt;There are quite a lot of quite expensive products positioning themselves as a revolutionary technology that can easily handle an overwhelming amount of Big Data querying and analytical processing, self-tuning, making no need for query tuning, prepared aggregations or calculations. There is no locking or logging overhead therefore data loading into the analytical DBMS is declared to be extremely fast. On the other hand, those DBMS admit that they are not built for the OLTP loads, massive updates and deletes are their weak point. &lt;/p&gt;  &lt;p&gt;The Data Warehouse team at my company has got to the decision that they need such analytical database solution. The vision is to have a scalable self-tuning database that will ingest terabyte or two on a weekly basis and will allow to any number of the concurrent users capability to execute an ad-hoc analytical queries on any period of time.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;I strongly believe that with the proper database design SQL Server 2012 can provide good performance under the heavy analytical workload. However, I was really curious to understand how the analytical databases achieve their self-tuning performance magic. There is nothing better than the competitors to show us where we have weaknesses that need some strengthening. &lt;/p&gt;  &lt;p&gt;First of all, here is a great map of all the technologies from the Big Data puzzle &lt;a title="http://www.bigdatamap.net/technologies/" href="http://www.bigdatamap.net/technologies/"&gt;http://www.bigdatamap.net/technologies/&lt;/a&gt; . &lt;/p&gt;  &lt;p&gt;In order to get a better understanding of the strong and weak points of the analytical databases world, I will drill down a little bit into the technologies that are standing behind the buzzwords. &lt;/p&gt;  &lt;p&gt;There are 4 categories of products inside the analytic databases part of the Data Repositories world:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font color="#000080"&gt;- In-Memory solutions (like SAP HANA, XtremeData, Kognitio etc.):&lt;/font&gt;&lt;/b&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;- When querying the DBMSs from this group, you are working primarily against the tables in the memory. Those DBMSs are the fastest solution in the analytical databases world. In-memory DBMS primary relies on the memory optimization algorithms which are much simpler than the disk access. There are no locking/ concurrency issues and queries are amazingly fast. With those systems you can expect sub-second results in the truly ad-hoc DWH workload with unpredictable queries coming through, sometimes in a size of 6 pages of the code. I have asked whether there are partitions on the tables and the Kognitio representative was quite surprised. “What for?” – he asked me.”Well, how do you delete the old data?”. “You just write a DELETE statement and data gets deleted” – he answered. That’s it. Just use DELETE statement.&lt;/p&gt;    &lt;p&gt;- There are several flavors of the in-memory products, each requires a different memory to data ratio. For instance, SAP HANA loads 100% of the database into the memory which makes this solution extremely expensive for the databases with hundreds of terabytes. Kognitio, on the other hand, allows you to choose which data goes into the memory, usually 20% - 40%, and the rest of the data stays in the persistency layer. For instance, if your queries usually access only last month data, you can have sliding window of this data in the memory and, in case any unpredicted query comes in, the system will load the missing data off the disc. However, on each cluster node 60% of memory will be used for data and the other 40% for the users activity and temporary calculations. When summed up you get to the quite pricey solution anyway. &lt;/p&gt;    &lt;p&gt;- All products in this category save the data to the disk as well. This persistency layer can be their proprietary files, Hadoop or any other DBMS.&lt;/p&gt;    &lt;p&gt;- One might think it will take time after the server downtime to get all data back into the memory. Kognitio states that it will take only 5 min for each 10 TB of data.&lt;/p&gt;    &lt;p&gt;- Watch out for some limitations coming along with in-memory architecture. Some products are not available during the maintenance tasks, like backups, or new nodes additions ( ExtremeData) and should be taken down. This does not suit the systems that must be up 24/7.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;&lt;font color="#000080"&gt;- Disk- oriented solutions (Vertica, Greenplum, Netezza, SybaseIQ, VectorWise, Microsoft PWD, etc.)&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;- Disk oriented products are very well optimized for working with the data on the disk. The main trend in this category is about storing the data in the columnar way which allows high compression ratio. However, some products are row-based like Netezza. Microsoft PDW ( V2 which is based on SQL 2012) allows both flavors of storage, rowbased and columnar. Their release is actually in February 2013 so we'll see how they will compete with the others.&lt;/p&gt;    &lt;p&gt;- Disk oriented solutions usually do not rely that there is a lot of RAM. &lt;/p&gt;    &lt;p&gt;- Since the world around us is row-based, all the columnar products are loading their data from the row-based files. They inject the incoming data into some write-optimized row store. The background process afterwards is converting the inserted data into the read-optimized sorted columnar storage. &lt;/p&gt;    &lt;p&gt;- Due to the fact that each column in columnar table is being stored in the separate file, the smaller the amount of requested columns the faster the queries perform. The wider queries usually require some sort of manual optimizations. Vertica, for instance is keeping several copies of the table, called projections. The projections, like covering indexes, contain columns grouped together or columns from different tables (for faster joins), nullifying the benefits of the compression. This is a hybrid columnar/row-based storage solution. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;nbsp;&lt;b&gt;&lt;font color="#000080"&gt;- Hybrid DBMS products ( ParAccel, Exasol, etc. )&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;- Those products are built on any disk-oriented technology, usually columnstores, but provide the best performance given as much RAM as they can get. For instance ParAccel submitted tcp-h benchmark on a system with 288% data/memory ratio.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#000080"&gt;&lt;b&gt;- Daemons running on the Hadoop nodes. (Claudera Impala)&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;- Kind of HIVE alternative, those solutions are running on the same physical cluster as Hadoop creating a seamless environment. Kognitio is considering such architecture as a future enhancement of their product.&lt;/p&gt;    &lt;p&gt;- Claudera Impala is a public beta, it goes out sometime in 2013. According to some web forum, the fastest Impala queries take &amp;gt; 1 second. Impala was tested and survived a load of 100 concurrent queries. Another test showed Impala running 10 cloned copies of a query with 25%~ish performance degradation.&lt;/p&gt;    &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;If you are evaluating an analytical database solution for your Big Data&lt;font color="#000000"&gt;, the features below can help you to understand better the different flavors of the products:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;b&gt;- &lt;font color="#004000"&gt;Product scalability&lt;/font&gt;.&lt;/b&gt;&lt;/font&gt; Scalability is about whether the product is MPP (massively parallel processing) system or single node system. MPP systems usually are built as a cluster of commodity servers where the tables data distributed across the cluster according to the administrator’s choice, like some sort of partitioning. Cluster nodes combined into a single very powerful analytic machine have vast amounts of processing power. New nodes can be easily added to the cluster when needed. Vertica, ParAccel, Exasol, Greenplum are the MPP solutions. Sybase IQ and VectorWise are single node systems though VectorWise promises that there is a MPP version coming out soon. &lt;/p&gt;  &lt;p&gt;- &lt;font color="#004000"&gt;&lt;b&gt;Single point of failure&lt;/b&gt;.&lt;/font&gt; While exploring an MPP product, it’s good to know if it’s share-nothing system or there is a main node (ParAccel, Netezza or Greenplum) that is in charge of producing query plans and processing the serial parts of the execution plans. For instance, the count distinct operation requires to run distinct sort again on the merged results. The main node might become a bottleneck in the future when the system load increases. &lt;/p&gt;  &lt;p&gt;&lt;font color="#004000"&gt;&lt;b&gt;- Replication factor/data redundancy.&lt;/b&gt;&lt;/font&gt; Most MPP solutions are replicating every subset of the data to an additional node for the redundancy. In case any node goes down, there is always another copy of the data which means that the cluster continues to work. The question is which kind of algorithm they use to store the second copy. Two phaze commit is too pricey because it slows down the inserts. And most of the products use optimistic approach. Each one implements that approach differently but the data is usually being replicated by the background process. What happens if the node failed after the data was inserted and before it has got replicated ?&lt;/p&gt;  &lt;p&gt;- Watch out for &lt;b&gt;&lt;font color="#004000"&gt;the limitations&lt;/font&gt;&lt;/b&gt;. VectorWise can support databases up to 30TB on single node. Another common limitation for the columnar solutions is character data type length. SAP HANA has the 2 billion records limit in a single partition.&lt;/p&gt;  &lt;p&gt;- &lt;b&gt;&lt;font color="#004000"&gt;Data Encryption.&lt;/font&gt;&lt;/b&gt; Most of the analytical databases that I have looked into did not have a data encryption feature. &lt;/p&gt;  &lt;p&gt;- &lt;font color="#004000"&gt;&lt;b&gt;Row to columnar conversion&lt;/b&gt;.&lt;/font&gt; The freshly loaded data querying is definitely worth a check. Especially on the column storage solutions. Your queries will probably be merging data from the write optimized row-based storage and column based files.&lt;/p&gt;  &lt;p&gt;&lt;font color="#004000"&gt;&lt;b&gt;- Data modifications.&lt;/b&gt;&lt;/font&gt; Vertical and Exasol are locking the entire table during the row modification operations ( updates/deletes) locking other modifying processes. I must note here that this does not impact read flows against that table.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font color="#004000"&gt;- Management tool&lt;/font&gt;&lt;/b&gt;. All this can sound great till you realize that your main tool will be the command line like in ParAccel. In such case you will probably need to purchase some third party management tool, like Toad. Make sure there is an ODBC/JDBC provider.&lt;/p&gt;  &lt;p&gt;- &lt;font color="#004000"&gt;&lt;b&gt;Languages support&lt;/b&gt;&lt;/font&gt;. Analytical solution should usually support ANSI SQL including analytical extensions. Many products support other languages, like R, JAVA, MDX etc.&lt;/p&gt;  &lt;p&gt;- &lt;font color="#004000"&gt;&lt;b&gt;Development/QA environment&lt;/b&gt;&lt;/font&gt; – It’s worth a check whether there it is possible to restore the production multi-node database to single-node server for development or testing purposes. &lt;/p&gt;  &lt;p&gt;- &lt;font color="#004000"&gt;&lt;b&gt;Hadoop connectivity.&lt;/b&gt;&lt;/font&gt; Many products have implemented this, it’s quite a useful feature, called External tables. This is very tight products integration, making Hadoop data visible for the user queries without pre-loading it. Although, integration might be not so tight for some products: under the hood they simply connect to Hadoop using the Hive and performance is slow in such cases. Kognitio, on the other hand, have an agent installed on the Hadoop cluster nodes and thus can “push down the predicates” – ask Hadoop to filter the data prior to loading.&lt;/p&gt;  &lt;p&gt;- &lt;font color="#004000"&gt;&lt;b&gt;Number of customers.&lt;/b&gt;&lt;/font&gt; If there are only 10 customers behind the revolutionary technology, would you consider paying a huge amount of money for it? &lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Machine generated data grows at the amazing speed therefore the requirements from the DBMS products are changing. SQL Server is evolving as well having a new columnstore index feature inside SQL 2012. In the next version more features from the analytical databases world will be implemented, like in-memory technology &amp;lt;Hekaton&amp;gt; , Hadoop External tables feature &amp;lt;Polybase&amp;gt; and true updatable columnnar data storage implemented by using new column-based clustered index.&lt;/p&gt;&lt;p&gt; Any software solution has it’s strength and there is no fit-for-everyone solution. There are many shades of grey besides the black and white colors.&lt;/p&gt;  &lt;p&gt;We are starting the POC for the several analytical DBMS. I will surely test the same load on SQL 2012. I accept the architectural limitation that it’s not scalable. I also understand that before Hekaton comes to town, SQL Server cannot compete with the in-memory products. However, I cannot wait to compare the performance of the columnstore index against the other columnstore products. &lt;/p&gt;&lt;p&gt;Are there any performance benchmarks between the columnar non-mpp product and SQL 2012 that you were a part of ?&lt;/p&gt;  &lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=46805" width="1" height="1"&gt;</content><author><name>Maria Zakourdaev</name><uri>http://www2.sqlblog.com/members/Maria+Zakourdaev.aspx</uri></author><category term="Analytical databases" scheme="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/tags/Analytical+databases/default.aspx" /></entry><entry><title>Real tortoises keep it slow and steady. How about the backups?</title><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/09/10/real-tortoises-keep-it-slow-and-steady-how-about-the-backups.aspx" /><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/09/10/real-tortoises-keep-it-slow-and-steady-how-about-the-backups.aspx</id><published>2012-09-10T10:54:00Z</published><updated>2012-09-10T10:54:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;… Four tortoises were playing in the backyard when they decided they needed hibiscus flower snacks. They pooled their money and sent the smallest tortoise out to fetch the snacks. &lt;br&gt;Two days passed and there was no sign of the tortoise.    &lt;br&gt;"You know, she is taking a lot of time", said one of the tortoises.     &lt;br&gt;A little voice from just out side the fence said, "If you are going to talk that way about me I won't go."&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_2ACDB5DD.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" width="110" height="108" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_2DEEB651.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Is it too much to request from the quite expensive 3rd party backup tool to be a way faster than the SQL server native backup? &lt;/p&gt;  &lt;p&gt;Or at least save a respectable amount of storage by producing a really smaller backup files?&amp;nbsp; By saying “really smaller”, I mean at least getting a file in half size.&lt;/p&gt;  &lt;p&gt;After Googling the internet in an attempt to understand what other “sql people” are using for database backups, I see that most people are using one of three tools which are the main players in SQL backup area:&amp;nbsp; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font color="#0000ff"&gt;LiteSpeed by Quest&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#0000ff"&gt;SQL Backup by Red Gate&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#0000ff"&gt;SQL Safe by Idera&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The feedbacks about those tools are truly emotional and happy. However, while reading the forums and blogs I have wondered, is it possible that many are accustomed to using the above tools since SQL 2000 and 2005.&amp;nbsp; &lt;br&gt;This can easily be understood due to the fact that a 300GB database backup for instance, using regular a SQL 2005 backup statement would have run for about 3 hours and have produced ~150GB file (depending on the content, of course).&amp;nbsp; &lt;br&gt;Then you take a 3rd party tool which performs the same backup in 30 minutes resulting in a 30GB file leaving you speechless, you run to management persuading them to buy it due to the fact that it is definitely worth the price.     &lt;br&gt;In addition to the increased speed and disk space savings you would also get backup file encryption and virtual restore -&amp;nbsp; features that are still missing from the SQL server. &lt;/p&gt;  &lt;p&gt;But in case you, as well as me, don’t need these additional features and only want a tool that performs a full backup MUCH faster &lt;b&gt;AND &lt;/b&gt;produces a far smaller backup file (like the gain you observed back in SQL 2005 days) you will be quite disappointed. SQL Server backup compression feature has totally changed the market picture.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;font color="#009b00"&gt;Medium size database.&lt;/font&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;Take a look at the table below, check out how my SQL server 2008 R2 compares to other tools when backing up&lt;b&gt; &lt;/b&gt;a&lt;b&gt; &lt;font color="#0000ff"&gt;300GB&lt;/font&gt;&lt;/b&gt; database. &lt;/p&gt;  &lt;p&gt;It appears that when talking about the backup speed, &lt;u&gt;SQL 2008 R2 compresses and performs backup in similar overall times&lt;/u&gt; as all three other tools. 3rd party tools maximum compression level takes twice longer.     &lt;br&gt;Backup file gain is not that impressive, except the highest compression levels but the price that you pay is very high cpu load and much longer time. Only SQL Safe by Idera was quite fast with it’s maximum compression level but most of the run time have used 95% cpu on the server.     &lt;br&gt;Note that I have used two types of destination storage, SATA 11 disks and FC 53 disks and, obviously, on faster storage have got my backup ready in half time.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_3E86B13F.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" width="908" height="366" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_64102EA0.png"&gt;&lt;/a&gt; &lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_3B251997.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" width="911" height="44" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_332D7735.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Looking at the above results, should we spend money, bother with another layer of complexity and software middle-man for the medium sized databases? I’m definitely not going to do so.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;font color="#009b00"&gt;Very large database&lt;/font&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;As a next phase of this benchmark, I have moved to a &lt;b&gt;&lt;font color="#0000ff"&gt;6 terabyte&lt;/font&gt;&lt;/b&gt; database which was actually my main backup target.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_2AC9A1DE.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="791" height="266" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_6544A1B2.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Note, how &lt;u&gt;multiple files usage enables the SQL Server backup operation to use parallel I/O and remarkably increases it’s speed, &lt;/u&gt;especially when the backup device is heavily striped. SQL Server supports a maximum of 64 backup devices for a single backup operation but the most speed is gained when using one file per CPU, in the case above 8 files for a 2 Quad CPU server. The impact of additional files is minimal.&amp;nbsp; &lt;br&gt;However, SQLsafe doesn’t show any speed improvement between 4 files and 8 files.&lt;/p&gt;  &lt;p&gt;Of course, with such huge databases every half percent of the compression transforms into the noticeable numbers. Saving almost 470GB of space may turn the backup tool into quite valuable purchase. Still, the backup speed and high CPU are the variables that should be taken into the consideration.&lt;/p&gt;  &lt;p&gt;As for us, the backup speed is more critical than the storage and we cannot allow a production server to sustain 95% cpu for such a long time.    &lt;br&gt;&lt;b&gt;&lt;u&gt;Bottomline, 3rd party backup tool developers, we are waiting for some breakthrough release.&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;There are a few unanswered questions, like the restore speed comparison between different tools and the impact of multiple backup files on restore operation. Stay tuned for the next benchmarks.&amp;nbsp; &lt;br&gt;&amp;nbsp;&lt;img width="134" height="101" src="http://embed.polyvoreimg.com/cgi/img-thing/size/y/tid/52397248.jpg"&gt;&lt;/p&gt;  &lt;p&gt;Benchmark server:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;SQL Server 2008 R2 sp1 &lt;/li&gt;    &lt;li&gt;2 Quad CPU &lt;/li&gt;    &lt;li&gt;Database location: NetApp FC 15K Aggregate 53 discs &lt;/li&gt;&lt;li&gt;Backup destination volumes: two physical NetApps&amp;nbsp;FC 15K Aggregate 53 discs, 4 files on each volume.&amp;nbsp;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Backup statements:&lt;/p&gt;  &lt;p&gt;No matter how good that UI is, we need to run the backup tasks from inside of SQL Server Agent to make sure they are covered by our monitoring systems. I have used extended stored procedures (command line execution also is an option, I haven’t noticed any impact on the backup performance). &lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2"&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;&lt;b&gt;SQL backup&lt;/b&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;&lt;b&gt;LiteSpeed&lt;/b&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;&lt;b&gt;SQL Backup&lt;/b&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;&lt;b&gt;SQL safe&lt;/b&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;&lt;font size="1"&gt;&lt;font color="#0000ff"&gt;backup database &lt;/font&gt;&amp;lt;DBNAME&amp;gt; &lt;font color="#0000ff"&gt;to &lt;/font&gt;&lt;/font&gt;            &lt;br&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;&lt;font color="#0000ff"&gt;disk&lt;/font&gt;&lt;/font&gt;= &lt;font color="#ff0000"&gt;'&lt;/font&gt;&lt;font size="1"&gt;&lt;font color="#ff0000"&gt;\\&amp;lt;networkpath&amp;gt;\par1.bak'&lt;/font&gt; &lt;/font&gt;,             &lt;br&gt;            &lt;br&gt;&lt;font size="1"&gt;&lt;font color="#0000ff"&gt;disk&lt;/font&gt;= '&lt;font color="#ff0000"&gt;\\&amp;lt;networkpath&amp;gt;\par2.bak'&lt;/font&gt;,&lt;/font&gt;             &lt;br&gt;            &lt;br&gt;&lt;font size="1"&gt;&lt;font color="#0000ff"&gt;disk&lt;/font&gt;= &lt;font color="#ff0000"&gt;'\\&amp;lt;networkpath&amp;gt;\par3.bak'&lt;/font&gt; &lt;/font&gt;            &lt;br&gt;            &lt;br&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;            &lt;br&gt;&lt;font color="#0000ff" size="1"&gt;with format, compression&lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;         &lt;p&gt;&lt;font size="1"&gt;&lt;font color="#0000ff"&gt;EXECUTE&lt;/font&gt; master.dbo.xp_backup_database&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@database =&lt;font color="#ff0000"&gt; N'&amp;lt;DBName&amp;gt;'&lt;/font&gt;, &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@backupname= &lt;font color="#ff0000"&gt;N'&amp;lt;DBName&amp;gt; full backup'&lt;/font&gt;, &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@desc = &lt;font color="#ff0000"&gt;N'Test'&lt;/font&gt;, &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@compressionlevel=8, &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@filename= &lt;font color="#ff0000"&gt;N'\\&amp;lt;networkpath&amp;gt;\par1.bak'&lt;/font&gt;, &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@filename= &lt;font color="#ff0000"&gt;N'\\&amp;lt;networkpath&amp;gt;\par2.bak'&lt;/font&gt;, &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@filename= &lt;font color="#ff0000"&gt;N'\\&amp;lt;networkpath&amp;gt;\par3.bak'&lt;/font&gt;,               &lt;br&gt;@init = 1&lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;         &lt;p&gt;&lt;font size="1"&gt;&lt;font color="#0000ff"&gt;EXECUTE&lt;/font&gt; master.dbo.sqlbackup               &lt;br&gt;&lt;/font&gt;&lt;font color="#ff0000" size="1"&gt;'-SQL "BACKUP DATABASE &amp;lt;DBNAME&amp;gt; &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font color="#ff0000" size="1"&gt;TO DISK= ''\\&amp;lt;networkpath&amp;gt;\par1.sqb'', &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font color="#ff0000" size="1"&gt;DISK= ''\\&amp;lt;networkpath&amp;gt;\par2.sqb'', &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font color="#ff0000" size="1"&gt;DISK= ''\\&amp;lt;networkpath&amp;gt;\par3.sqb'' &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font color="#ff0000" size="1"&gt;WITH &lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font color="#ff0000" size="1"&gt;DISKRETRYINTERVAL = 30,              &lt;br&gt;DISKRETRYCOUNT = 10,               &lt;br&gt;COMPRESSION = 4,               &lt;br&gt;INIT"' &lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;         &lt;p&gt;&lt;font size="1"&gt;&lt;font color="#0000ff"&gt;EXECUTE&lt;/font&gt; &lt;/font&gt;&lt;font size="1"&gt;master.dbo.&lt;/font&gt;&lt;a href="mailto:master.dbo.xp_ss_backup@database"&gt;&lt;font size="1"&gt;xp_ss_backup&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@database = &lt;font color="#ff0000"&gt;'UCMSDB'&lt;/font&gt;,&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@filename = &lt;font color="#ff0000"&gt;'\\&lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000" size="1"&gt;&amp;lt;networkpath&amp;gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;font color="#ff0000"&gt;\par1.bak'&lt;/font&gt;,&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@backuptype = &lt;font color="#ff0000"&gt;'Full'&lt;/font&gt;,&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@compressionlevel = 4,&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@backupfile = '&lt;font color="#ff0000"&gt;\\&lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000" size="1"&gt;&amp;lt;networkpath&amp;gt;&lt;/font&gt;&lt;font size="1"&gt;&lt;font color="#ff0000"&gt;\par2.bak'&lt;/font&gt;,&lt;/font&gt;&lt;/p&gt;          &lt;p&gt;&lt;font size="1"&gt;@backupfile =&lt;font color="#ff0000"&gt; '\\&lt;/font&gt;&lt;/font&gt;&lt;font color="#ff0000"&gt;&lt;font size="1"&gt;&amp;lt;networkpath&amp;gt;&lt;/font&gt;&lt;font size="1"&gt;\par3.bak'&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;If you still insist on using 3rd party tools for the backups in your production environment with maximum compression level, you will definitely need to consider limiting cpu usage which will increase the backup operation time even more: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;RedGate&lt;/b&gt; : use THREADPRIORITY option ( values 0 – 6 ) &lt;/li&gt;    &lt;li&gt;&lt;b&gt;LiteSpeed&lt;/b&gt; : use&amp;nbsp; @throttle ( percentage, like 70%) &lt;/li&gt;    &lt;li&gt;&lt;b&gt;SQL safe&lt;/b&gt; :&amp;nbsp; the only thing I have found was @Threads option. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Yours,&lt;/p&gt;  &lt;p&gt;Maria&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=45104" width="1" height="1"&gt;</content><author><name>Maria Zakourdaev</name><uri>http://www2.sqlblog.com/members/Maria+Zakourdaev.aspx</uri></author><category term="backup" scheme="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/tags/backup/default.aspx" /></entry><entry><title>Is your TRY worth catching?</title><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/06/06/is-your-try-worth-catching.aspx" /><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/06/06/is-your-try-worth-catching.aspx</id><published>2012-06-06T12:54:00Z</published><updated>2012-06-06T12:54:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;A very useful error handling &lt;font color="#0000ff"&gt;&lt;b&gt;TRY/CATCH&lt;/b&gt;&lt;/font&gt; construct is widely used to catch all execution errors&amp;nbsp; that do not close the database connection. The biggest downside is that in the case of multiple errors the &lt;b&gt;&lt;font color="#0000ff"&gt;TRY/CATCH&lt;/font&gt;&lt;/b&gt; mechanism will only catch the last error. &lt;/p&gt;  &lt;p&gt;An example of this can be seen during a standard restore operation. In this example I attempt to perform a restore from a file that no longer exists. Two errors are being fired: &lt;font color="#ff0000"&gt;&lt;b&gt;3201&lt;/b&gt;&lt;/font&gt; and &lt;b&gt;&lt;font color="#ff0000"&gt;3013&lt;/font&gt;&lt;/b&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_1FA0B330.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="738" height="163" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_15F844FA.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Assuming that we are using the &lt;b&gt;&lt;font color="#0000ff"&gt;TRY&lt;/font&gt;&lt;/b&gt; and &lt;b&gt;&lt;font color="#0000ff"&gt;CATCH&lt;/font&gt;&lt;/b&gt; construct, the &lt;b&gt;&lt;font color="#d16349"&gt;ERROR_MESSAGE&lt;/font&gt;&lt;font color="#a5a5a5"&gt;()&lt;/font&gt;&lt;/b&gt; function will catch the last message only:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_0700F013.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="627" height="300" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_50AFC803.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To workaround this problem you can prepare a temporary table that will receive the statement output. Execute the statement inside the &lt;b&gt;&lt;font color="#9e7c7c"&gt;xp_cmdshell&lt;/font&gt;&lt;/b&gt; stored procedure, connect back to the SQL Server using the command line utility &lt;b&gt;&lt;font color="#9e7c7c"&gt;sqlcmd&lt;/font&gt;&lt;/b&gt; and redirect it's output into the previously created temp table.&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_5CD1422A.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="650" height="279" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_0D1816E1.png"&gt;&lt;/a&gt;&lt;/p&gt;        &lt;p&gt;After receiving the output, you will need to parse it to understand whether the statement has finished successfully or failed. It’s quite easy to accomplish as long as you know which statement was executed. In the case of generic executions you can query the output table and search for words like&lt;font color="#c0504d"&gt;&lt;b&gt;“Msg%Level%State%”&lt;/b&gt;&lt;/font&gt;&amp;nbsp;that are usually a part of the error message.&lt;/p&gt;&lt;p&gt;Furthermore, you don’t need TRY/CATCH in the above workaround, since the&amp;nbsp;&lt;b&gt;&lt;font color="#9e7c7c"&gt;xp_cmdshell&lt;/font&gt;&lt;/b&gt;&amp;nbsp;procedure always finishes successfully and you can decide whether to fire the&amp;nbsp;&lt;b&gt;&lt;font color="#0000ff"&gt;RAISERROR&lt;/font&gt;&lt;/b&gt;&amp;nbsp;statement or not.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Yours,&lt;/p&gt;  &lt;p&gt;Maria&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=43747" width="1" height="1"&gt;</content><author><name>Maria Zakourdaev</name><uri>http://www2.sqlblog.com/members/Maria+Zakourdaev.aspx</uri></author></entry><entry><title>SQLCMD Mode: give it one more chance</title><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/05/11/sqlcmd-mode-give-it-one-more-chance.aspx" /><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/05/11/sqlcmd-mode-give-it-one-more-chance.aspx</id><published>2012-05-11T13:26:00Z</published><updated>2012-05-11T13:26:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;- Click on me. Choose me. - asked one forgotten &lt;font color="#000000"&gt;feature when some bored DBA was purposelessly&lt;/font&gt; wondering through the Management Studio menu at the end of her long and busy working day.&lt;/p&gt;  &lt;p&gt;- Why would I use you? I have heard of no one who does. What are you for? - perplexedly wondered aged and wise DBA. At least that DBA thought she was aged and wise though each day tried to prove to her that she wasn't. &lt;/p&gt;  &lt;p&gt;- I know you. You are quite lazy. Why would you do additional clicks to move from window to window? From Tool to tool ? This is irritating, isn't it? I can run windows system commands, sql statements and much more from the same script, from the same query window!&lt;/p&gt;  &lt;p&gt;- I have all my tools that I‘m used to, I have Management Studio, Cmd, Powershell. They can do anything for me. I don’t need additional tools.&lt;/p&gt;  &lt;p&gt;- I promise you, you will like me. – the thing continued to whine .&lt;/p&gt;  &lt;p&gt;- All right, show me. – she gave up. It’s always this way, she thought sadly, - easier to agree than to explain why you don’t want.&lt;/p&gt;  &lt;p&gt;- Enable me and then think about anything that you always couldn’t do through the management studio and had to use other tools. &lt;/p&gt;  &lt;p&gt;- Ok. Google for me the list of greatest features of SQL SERVER 2012.&lt;/p&gt;  &lt;p&gt;- Well... I’m not sure... Think about something else. &lt;/p&gt;  &lt;p&gt;- Ok, here is something easy for you. I want to check if file folder exists or if file is there. Though, I can easily do this using xp_cmdshell …&lt;/p&gt;  &lt;p&gt;- This is easy for me. – rejoiced the feature. &lt;/p&gt;  &lt;p&gt;By the way, having the items of the menu talking to you usually means you should stop working and go home. Or drink coffee. Or both. Well, aged and wise dba wasn’t thinking about the weirdness of the situation at that moment.&lt;/p&gt;  &lt;p&gt;- After enabling me, – said unfairly forgotten feature (it was thinking of itself in such manner) – after enabling me you can use all command line commands in the same management studio query window by adding two exclamation marks &lt;font style="background-color:#00ff00;"&gt;!!&lt;/font&gt; at the beginning of the script line to denote that you want to use cmd command:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_5FBC6A4C.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="477" height="327" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_0BC94171.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;-Just keep in mind that when using this feature, you are actually running the commands ON YOUR computer and not on SQL server that query window is connected to. This is main difference from using xp_cmdshell which is executing commands on sql server itself. Bottomline, use UNC path instead of local path. &lt;/p&gt;  &lt;p&gt;- Look, there are much more than that. - The SQLCMD feature was getting exited.- You can get IP of your servers, create, rename and drop folders. You can see the contents of any file anywhere and even start different tools from the same query window:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_3D7438F9.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="463" height="463" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_4D33CDFD.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Not so aged and wise DBA was getting interested: - I also want to run different scripts on different servers without changing connection of the query window. &lt;/p&gt;  &lt;p&gt;- Sure, sure! Another great feature that CMDmode is providing us with and giving more power to querying. Use &lt;font style="background-color:#00ff00;"&gt;“:”&lt;/font&gt; to use additional features, like &lt;font style="background-color:#00ff00;"&gt;:connect&lt;/font&gt; that allows you to change connection: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_3861D57D.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="460" height="369" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_3ABB577B.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- Now imagine, you have one script where you have all your changes, like creating staging table on the DWH staging server, adding fact table to DWH itself and updating stored procedures in the server where reporting database is located.&lt;/p&gt;  &lt;p&gt;- Now, give me more challenges!&lt;/p&gt;  &lt;p&gt;- Script out a list of stored procedures into the text files. &lt;/p&gt;  &lt;p&gt;- You can do it easily by using command&lt;font style="background-color:#00ff00;"&gt; :out&lt;/font&gt; which will write the query results into the specified text file. The output can be the code of the stored procedure or any data. Actually this is the same as changing the query output into the file instead of the grid.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_18171900.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="452" height="411" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_15FA1A37.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- Now, take all of the scripts and run all of them, one by one, on the different server.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;- Easily &lt;/p&gt;  &lt;p&gt;- Come on... I’m sure that you can not...&lt;/p&gt;  &lt;p&gt;-Why not? Naturally, I can do it using &lt;font style="background-color:#00ff00;"&gt;:r&lt;/font&gt; commant which is opening a script and executing it. Look, I can also use &lt;font style="background-color:#00ff00;"&gt;:setvar&lt;/font&gt; command to define an environment variable in SQLCMD mode. Just note that you have to leave the empty string between :r commands, otherwise it’s not working although I have no idea why.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_012821B7.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="362" height="202" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_1153E9B0.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- Wow.- She was really impressed. - Ok, I’ll go to try all those…&lt;/p&gt;  &lt;p&gt;-Wait, wait! I know how to google the SQL SERVER features for you! This example will open chrome explorer with search results for the “SQL server 2012 top features” ( change the path to suit your PC): &lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_11DFA698.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" width="1027" height="149" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_6FA79B11.png"&gt;&lt;/a&gt;&lt;/p&gt;                            &lt;p&gt;“Well, this can be probably useful stuff, maybe this feature is really unfairly forgotten”, thought the DBA while going through the dark empty parking lot to her lonely car. “As someone really wise once said: “It is what we think we know that keeps us from learning. Learn, unlearn and relearn”.&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=43318" width="1" height="1"&gt;</content><author><name>Maria Zakourdaev</name><uri>http://www2.sqlblog.com/members/Maria+Zakourdaev.aspx</uri></author><category term="sqlcmd" scheme="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/tags/sqlcmd/default.aspx" /></entry><entry><title>Maintenance plans love story</title><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/04/05/maintenance-plans-love-story.aspx" /><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/04/05/maintenance-plans-love-story.aspx</id><published>2012-04-05T07:00:00Z</published><updated>2012-04-05T07:00:00Z</updated><content type="html">&lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;There are about 200 QA and DEV SQL Servers out there.&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:11pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;There is a maintenance plan on many of them that performs a backup of all databases and removes the backup history files. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;First of all, I must admit that I’m no big fan of maintenance plans in particular or the SSIS packages in general.&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:11pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;In this specific case, if I ever need to change anything in the way backup is performed, such as the compression feature or perform some other change, I have to open each plan one by one. This is quite a pain. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;Therefore, I have decided to replace the maintenance plans with a stored procedure that will perform exactly the same thing.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Having such a procedure will allow me to open multiple server connections and just execute an ALTER PROCEDURE whenever I need to change anything in it. There is nothing like good ole T-SQL.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;The first challenge was to remove the unneeded maintenance plans. Of course, I didn’t want to do it server by server.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;I found the procedure msdb.dbo.&lt;/font&gt;&lt;/font&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#800000"&gt;sp_maintplan_delete_plan&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;, but it only has a parameter for the maintenance plan id and it has no other parameters, like plan name, which would have been much more useful. Now I needed to find the table that holds all maintenance plans on the server. You would think that it would be msdb.dbo.sysdbmaintplans but, unfortunately, regardless of the number of maintenance plans on the instance, it contains just one row.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/clip_image0028_30054E5D.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image002[8]" border="0" alt="clip_image002[8]" width="686" height="206" src="http://sqlblog.com/blogs/maria_zakourdaev/clip_image0028_thumb_2E548289.jpg"&gt;&lt;/a&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;After a while I found another table: msdb.dbo.sysmaintplan_subplans. It contains the plan id that I was looking for, in the plan_id column and well as the agent’s job id which is executing the plan’s package:&lt;/font&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;span style="mso-no-proof:yes;"&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/clip_image0048_217A2C6B.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image004[8]" border="0" alt="clip_image004[8]" width="780" height="152" src="http://sqlblog.com/blogs/maria_zakourdaev/clip_image0048_thumb_43EEBB26.jpg"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;That was all I needed and the rest turned out to be quite easy.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;Here is a script that can be executed against hundreds of servers from a multi-server query window to drop the specific maintenance plans. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;DECLARE&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; @PlanID &lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;uniqueidentifier&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;SELECT&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; @PlanID &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; plan_id&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;FROM&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; msdb&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;dbo&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;sysmaintplan_subplans&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;"&gt;Where name like ‘BackupPlan%’&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;EXECUTE&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; msdb&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;dbo&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#800000"&gt;sp_maintplan_delete_plan&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;@plan_id&lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt;@PlanID&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;span style="mso-no-proof:yes;"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;The second step was to create a procedure that will perform &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;all of the old maintenance plan tasks: create a folder for each database, backup all databases on the server and clean up the old files. The script is below. Enjoy.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:8pt;"&gt;ALTER&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:8pt;"&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;PROCEDURE&lt;/font&gt;&lt;/span&gt; BackupAllDatabases&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:5;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;@PrintMode &lt;span&gt;&lt;font color="#0000ff"&gt;BIT&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 1&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;" color="#0000ff"&gt;AS&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;" color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;" color="#0000ff"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;DECLARE&lt;/font&gt;&lt;/span&gt; @BackupLocation &lt;span&gt;&lt;font color="#0000ff"&gt;VARCHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;500&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;DECLARE&lt;/font&gt;&lt;/span&gt; @PurgeAferDays &lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#0000ff"&gt;INT&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;DECLARE&lt;/font&gt;&lt;/span&gt; @PurgingDate &lt;span&gt;&lt;font color="#0000ff"&gt;VARCHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;30&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;DECLARE&lt;/font&gt;&lt;/span&gt; @SQLCmd&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;VARCHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff00ff"&gt;MAX&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;DECLARE&lt;/font&gt;&lt;/span&gt; @FileName&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;VARCHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;100&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;SET&lt;/font&gt;&lt;/span&gt; @PurgeAferDays &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;-&lt;/font&gt;&lt;/span&gt;14&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;SET&lt;/font&gt;&lt;/span&gt; @BackupLocation &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff0000"&gt;'\\central_storage_servername\BACKUPS\'&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#ff00ff"&gt;@@servername&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;SET&lt;/font&gt;&lt;/span&gt; @PurgingDate &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff00ff"&gt;CONVERT&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;VARCHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;19&lt;span&gt;&lt;font color="#808080"&gt;),&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff00ff"&gt;DATEADD&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;dd&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;@PurgeAferDays&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff00ff"&gt;GETDATE&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;()),&lt;/font&gt;&lt;/span&gt;126&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;SET&lt;/font&gt;&lt;/span&gt; @FileName &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff0000"&gt;'?_full_'&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff00ff"&gt;REPLACE&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff00ff"&gt;CONVERT&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;VARCHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;19&lt;span&gt;&lt;font color="#808080"&gt;),&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff00ff"&gt;GETDATE&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(),&lt;/font&gt;&lt;/span&gt;126&lt;span&gt;&lt;font color="#808080"&gt;),&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;':'&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;'-'&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;'.bak'&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;" color="#808080"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;SET&lt;/font&gt;&lt;/span&gt; @SQLCmd &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#ff0000"&gt;'&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;IF ''?'' &amp;lt;&amp;gt; ''tempdb'' BEGIN&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;EXECUTE master.dbo.xp_create_subdir N'''&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:8pt;"&gt;@BackupLocation&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#ff0000"&gt;'\?\'' ;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;" color="#ff0000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;BACKUP DATABASE ? TO&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;DISK = N'''&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:8pt;"&gt;@BackupLocation&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;'\?\'&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;@FileName&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#ff0000"&gt;'''&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;WITH NOFORMAT, NOINIT,&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;SKIP, REWIND, NOUNLOAD, COMPRESSION,&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;STATS = 10 ;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;" color="#ff0000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;EXECUTE master.dbo.xp_delete_file 0,N'''&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:8pt;"&gt;@BackupLocation&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;'\?\'',N''bak'',N'''&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;@PurgingDate&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#ff0000"&gt;''',1;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;END'&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;" color="#ff0000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;IF&lt;/font&gt;&lt;/span&gt; @PrintMode &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 1 &lt;/font&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;PRINT&lt;/font&gt;&lt;/span&gt; @SQLCmd&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font style="font-size:8pt;" color="#0000ff"&gt;END&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:8pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;EXEC&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#800000"&gt;sp_MSforeachdb&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;@SQLCmd&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:8pt;" color="#0000ff"&gt;END&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=41974" width="1" height="1"&gt;</content><author><name>Maria Zakourdaev</name><uri>http://www2.sqlblog.com/members/Maria+Zakourdaev.aspx</uri></author></entry><entry><title>Transactional replication: are you sure your data is totally synchronized?</title><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/03/06/transactional-replication-are-you-sure-your-data-is-totally-synchronized.aspx" /><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/03/06/transactional-replication-are-you-sure-your-data-is-totally-synchronized.aspx</id><published>2012-03-06T14:47:00Z</published><updated>2012-03-06T14:47:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;There are those rare times, when your replication solution is working perfectly. No consistency errors, no errors at all.    &lt;br&gt;Or so it seems. &lt;/p&gt;  &lt;p&gt;Then, all of a sudden, you catch one application which is writing to the read-only subscriber. Next, a developer complains that some data is missing from the subscriber. &lt;/p&gt;  &lt;p&gt;Similarly, you always wonder, after the consistency errors have appeared and solved, whether the data is synchronized. In some specific cases, the publication can be dropped by mistake and re-created with replication continuing without reporting any errors.&lt;/p&gt;  &lt;p&gt;Is there a native way to make sure all data is synchronized between the publisher and the subscriber?&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font color="#4f81bd"&gt;&lt;u&gt;Validate subscriptions using Replication Monitor&lt;/u&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;If you open the Replication Monitor application and right click on your publication, you will notice the “Validate subscriptions…” feature.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_390967B0.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" width="285" height="188" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_3D9F726A.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click on it, choose the subscription that requires validation and select the way validation will be performed.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/image_4DCB3A63.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" width="478" height="328" src="http://sqlblog.com/blogs/maria_zakourdaev/image_thumb_11BEF8AE.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;These options are quite critical since they directly impact the speed of the validation process. Here you can choose whether the tables themselves will be queried or row number information will be extracted from the sysindexes system view. &lt;/p&gt;  &lt;p&gt;The default option is to compare the numbers from sysindexes and compare actual row counts only in case the differences were found. &lt;/p&gt;  &lt;p&gt;You can also choose to compare the checksums of the data. In this case, the validation process will take a long time. &lt;/p&gt;  &lt;p&gt;The result of the comparison will appear in the distribution service details:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/clip_image005_3A0E2B02.jpg"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="clip_image005" border="0" alt="clip_image005" width="580" height="192" src="http://sqlblog.com/blogs/maria_zakourdaev/clip_image005_thumb_06D1F199.jpg"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You will see all tables that were scanned by the validation process and the row counts. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/clip_image007_7E6E1C41.jpg"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="clip_image007" border="0" alt="clip_image007" width="628" height="349" src="http://sqlblog.com/blogs/maria_zakourdaev/clip_image007_thumb_5178B966.jpg"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If a table is out of sync you will see the error as below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/clip_image009_48A8B11A.jpg"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="clip_image009" border="0" alt="clip_image009" width="775" height="75" src="http://sqlblog.com/blogs/maria_zakourdaev/clip_image009_thumb_723C7C4D.jpg"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;font color="#4f81bd"&gt;&lt;u&gt;What’s going on behind the scenes? &lt;/u&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Here is the query that is being executed against each table in the database if you choose to compare actual count and the checksum:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;SELECT&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; &lt;span&gt;&lt;font color="#ff00ff"&gt;count_big&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(*),&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff00ff"&gt;sum&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff00ff"&gt;convert&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;numeric&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff00ff"&gt;binary_checksum&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(*)&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;FROM&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; &lt;span&gt;&lt;font color="#808080"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;tablename&lt;span&gt;&lt;font color="#808080"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;WITH &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;TABLOCK&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;HOLDLOCK&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&amp;nbsp;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font color="#808080" size="2" face="Courier New"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font color="#808080" size="2" face="Courier New"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;All the above is nice when you have only one publication to validate. &lt;b&gt;What if you have hundreds of publications?&lt;/b&gt; &lt;/p&gt;  &lt;p&gt;As you might have expected, this UI is executing the stored procedure on the publisher. The stored procedure is called &lt;b&gt;sp_publication_validation&lt;/b&gt; and it’s main parameters are&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;&lt;b&gt;&lt;i&gt;@rowcount_only&lt;/i&gt;&lt;/b&gt; &lt;/font&gt;&lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p style="line-height:13pt;list-style-type:disc;text-indent:-0.25in;margin:0in 0in 0pt 1.5in;mso-list:l0 level3 lfo1;mso-add-space:auto;" class="MsoListParagraphCxSpMiddle" align="left"&gt;&lt;span style="font-family:;mso-fareast-font-family:wingdings;mso-bidi-font-family:wingdings;"&gt;&lt;span style="mso-list:ignore;"&gt;&lt;font face="Wingdings"&gt;&lt;font style="font-size:11pt;"&gt;§&lt;/font&gt;&lt;/font&gt;&lt;span style="line-height:normal;font-family:;"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size:7pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;1 - Perform a rowcount check only &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;( default )&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;text-indent:-0.25in;margin:0in 0in 0pt 1.5in;mso-list:l0 level3 lfo1;mso-add-space:auto;" class="MsoListParagraphCxSpMiddle" align="left"&gt;&lt;span style="font-family:;mso-fareast-font-family:wingdings;mso-bidi-font-family:wingdings;"&gt;&lt;span style="mso-list:ignore;"&gt;&lt;font face="Wingdings"&gt;&lt;font style="font-size:11pt;"&gt;§&lt;/font&gt;&lt;/font&gt;&lt;span style="line-height:normal;font-family:;"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size:7pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;2 - Perform a rowcount and binary checksum&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;text-indent:-0.25in;margin:0in 0in 0pt 1.5in;mso-list:l0 level3 lfo1;mso-add-space:auto;" class="MsoListParagraphCxSpMiddle" align="left"&gt;&lt;font face="Calibri"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div style="line-height:13pt;list-style-type:disc;text-indent:-0.25in;margin:0in 0in 0pt 0.5in;mso-list:l0 level1 lfo1;" class="MsoListParagraphCxSpMiddle" align="left"&gt;&lt;b&gt;&lt;i&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;@full_or_fast &lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p style="line-height:13pt;list-style-type:disc;text-indent:-0.25in;margin:0in 0in 0pt 1.5in;mso-list:l0 level3 lfo1;mso-add-space:auto;" class="MsoListParagraphCxSpMiddle" align="left"&gt;&lt;span style="font-family:;mso-fareast-font-family:wingdings;mso-bidi-font-family:wingdings;"&gt;&lt;span style="mso-list:ignore;"&gt;&lt;font face="Wingdings"&gt;&lt;font style="font-size:11pt;"&gt;§&lt;/font&gt;&lt;/font&gt;&lt;span style="line-height:normal;font-family:;"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size:7pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;0 – Full count using count(*)&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;text-indent:-0.25in;margin:0in 0in 0pt 1.5in;mso-list:l0 level3 lfo1;mso-add-space:auto;" class="MsoListParagraphCxSpMiddle" align="left"&gt;&lt;span style="font-family:;mso-fareast-font-family:wingdings;mso-bidi-font-family:wingdings;"&gt;&lt;span style="mso-list:ignore;"&gt;&lt;font face="Wingdings"&gt;&lt;font style="font-size:11pt;"&gt;§&lt;/font&gt;&lt;/font&gt;&lt;span style="line-height:normal;font-family:;"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size:7pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;1 – Fast count using sysindexes view&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;text-indent:-0.25in;margin:0in 0in 10pt 1.5in;mso-list:l0 level3 lfo1;mso-add-space:auto;" class="MsoListParagraphCxSpLast" align="left"&gt;&lt;span style="font-family:;mso-fareast-font-family:wingdings;mso-bidi-font-family:wingdings;"&gt;&lt;span style="mso-list:ignore;"&gt;&lt;font face="Wingdings"&gt;&lt;font style="font-size:11pt;"&gt;§&lt;/font&gt;&lt;/font&gt;&lt;span style="line-height:normal;font-family:;"&gt;&lt;font face="Times New Roman"&gt;&lt;font style="font-size:7pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;2 – Compare the subscriber and publisher using the fast count and, if the results are not equal, uses count on table. If the rows field in sysindexes is NULL full count will be used. ( default )&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;USE&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; &lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;&amp;lt;published database&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;GO &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;EXEC&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; &lt;span&gt;&lt;font color="#800000"&gt;sp_publication_validation&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#0000ff"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;@publication &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#ff0000"&gt;'PublicationName'&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@rowcount_only &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;2 &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@full_or_fast &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;2&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;You can execute this stored procedure over all publications on the server.&lt;/p&gt;  &lt;p&gt;I have put together a simple script to do this, in order to use it you need to define a linked server to the Distributor server in order to get a list of publications from the &lt;b&gt;MSpublications &lt;/b&gt;table which is located in the Distribution database.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;CREATE&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;PROCEDURE&lt;/font&gt;&lt;/span&gt; ValidateSubscriptions &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:4;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;@PrintMode&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 0&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;AS&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;DECLARE&lt;/font&gt;&lt;/span&gt; @SQLCmd&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;varchar&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff00ff"&gt;max&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#808080"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;SET&lt;/font&gt;&lt;/span&gt; @SQLCmd&lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#ff0000"&gt;''&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#ff0000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;SELECT&lt;/font&gt;&lt;/span&gt; @SQLCmd &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; @SQLCmd &lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#ff0000"&gt;'EXEC ['&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;publisher_db&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;&lt;font style="font-size:10pt;"&gt;'].dbo.sp_publication_validation&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;@publication = '''&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt;publication&lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#ff0000"&gt;''',&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;@rowcount_only =&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;2, &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;@full_or_fast =&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;2;'&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; &lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;CHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;10&lt;span&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;CHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;13&lt;span&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;' WAITFOR DELAY ''00:01:00'';'&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;CHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;10&lt;span&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#808080"&gt;+&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;CHAR&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;13&lt;span&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;FROM&lt;/font&gt;&lt;/span&gt; DISTRIBUTOR&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;DistributionDB&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;dbo&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;MSpublications p&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#808080"&gt;JOIN&lt;/font&gt;&lt;/span&gt; DISTRIBUTOR&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;master&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#008000"&gt;sys&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#008000"&gt;servers&lt;/font&gt;&lt;/span&gt; s&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;ON&lt;/font&gt;&lt;/span&gt; p&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;publisher_id &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; s&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;server_id&lt;/font&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; s&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;name &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#ff00ff"&gt;@@servername&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;IF&lt;/font&gt;&lt;/span&gt; @PrintMode &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 1 &lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;PRINT&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@SQLCmd&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;END&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;EXEC &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;@SQLCmd&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#808080"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;END&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;All the validation results (for all publications) will be inserted into the &lt;b&gt;MSdistribution_history&lt;/b&gt; table which is located in the Distribution database on the Distributor server.&lt;/p&gt;  &lt;p&gt;Viewing it can be done using the following query:&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;USE&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; DistributionDB&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;GO&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;font style="font-size:10pt;" color="#0000ff"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;SELECT&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;time&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Time&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;s&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;Name&lt;span style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;PublisherServer&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;a&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;publication&lt;span style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Publication&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;s2&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;name&lt;span style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SubscriberServer&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin:0in 0in 0pt 1in;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#ff00ff"&gt;&lt;font style="font-size:10pt;"&gt;SUBSTRING&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt;comments&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;8&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff00ff"&gt;CHARINDEX&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;''''&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;comments&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;8&lt;span&gt;&lt;font color="#808080"&gt;)-&lt;/font&gt;&lt;/span&gt;8&lt;span&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt; TableName&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:2;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;comments&lt;span style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Comments&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;FROM&lt;/font&gt;&lt;/span&gt; dbo&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;MSdistribution_history&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;h&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;JOIN&lt;/font&gt;&lt;/span&gt; dbo&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;MSdistribution_agents&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;a &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;ON&lt;/font&gt;&lt;/span&gt; h&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;agent_id &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; a&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;id &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#808080"&gt;JOIN&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;master&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#008000"&gt;sys&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#008000"&gt;servers&lt;/font&gt;&lt;/span&gt; s&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:3;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;ON&lt;/font&gt;&lt;/span&gt; a&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;publisher_id &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; s&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;server_id&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:4;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#808080"&gt;JOIN&lt;/font&gt;&lt;/span&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;master&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#008000"&gt;sys&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#008000"&gt;servers&lt;/font&gt;&lt;/span&gt; s2&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:4;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;ON&lt;/font&gt;&lt;/span&gt; a&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;subscriber_id &lt;span&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; s2&lt;span&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;server_id&lt;span style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;span style="line-height:12pt;font-family:;mso-no-proof:yes;"&gt;&lt;font face="Courier New"&gt;&lt;span style="mso-tab-count:1;"&gt;&lt;font style="font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:10pt;"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;WHERE&lt;/font&gt;&lt;/span&gt; comments &lt;span&gt;&lt;font color="#808080"&gt;like&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#ff0000"&gt;'Table %'&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;The best part is that if any article fails validation you will immediately see it in the error log&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p style="line-height:normal;list-style-type:disc;margin-bottom:0pt;mso-layout-grid-align:none;" class="MsoNormal" align="left"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:10pt;"&gt;EXEC&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="font-family:;mso-no-proof:yes;"&gt;&lt;font style="font-size:10pt;"&gt; &lt;span&gt;&lt;font color="#0000ff"&gt;master&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;..&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#800000"&gt;xp_readerrorlog&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;0&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;1&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:10pt;" color="#ff0000"&gt;'failed data validation'&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/clip_image011_45B34C67.jpg"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="clip_image011" border="0" alt="clip_image011" width="978" height="106" src="http://sqlblog.com/blogs/maria_zakourdaev/clip_image011_thumb_2B72E343.jpg"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The above means that if you have some usual routine that notifies you in case there are any unusual errors in the SQL Server Error Log, it will show validation failures as well.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;May all your articles pass their validation successfully.&lt;/p&gt;  &lt;p&gt;Yours, Maria&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=42119" width="1" height="1"&gt;</content><author><name>Maria Zakourdaev</name><uri>http://www2.sqlblog.com/members/Maria+Zakourdaev.aspx</uri></author></entry><entry><title>Unfairly forgotten partitioning views can help us make our partitioning tables design better</title><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/02/28/unfairly-forgotten-partitioning-views-can-help-us-make-our-partitioning-tables-design-better.aspx" /><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/02/28/unfairly-forgotten-partitioning-views-can-help-us-make-our-partitioning-tables-design-better.aspx</id><published>2012-02-28T08:12:00Z</published><updated>2012-02-28T08:12:00Z</updated><content type="html">&lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;Partitioning is a very important feature for scalable applications, it allows breaking up huge monolithic tables in order to ensure their scalability &amp;amp; manageability within a single instance. For example, data deletion and loading can be very fast if done by partition. Reorganizing, optimizing and rebuilding indices also can be done by partition which is much less intrusive and faster.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;Also, when talking about performance, joins become faster when using tables that are partitioned. Smaller b-trees for each partition make partition access fast, especially when limiting rows by a partition key, accessing only a subset of data. Another performance benefit can be achieved when using partition level lock escalation.&lt;/font&gt;&lt;span style="mso-no-proof:yes;"&gt;&lt;font style="font-size:11pt;"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;span style="mso-no-proof:yes;"&gt;&lt;font style="font-size:11pt;"&gt;There are two partitioning designs in the SQL Server. In a partitioned view, the member tables are horizontally joined by a view, so from the user’s perspective, the data comes from one table. A natively partitioned table, a feature &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:11pt;"&gt;introduced in SQL Server 2005, is treated as a single object by the relational engine, yet is handled as multiple objects by the storage engine.&lt;/font&gt;&lt;span style="mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;span style="mso-no-proof:yes;"&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/clip_image002_3FB00494.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image002" border="0" alt="clip_image002" width="420" height="311" src="http://sqlblog.com/blogs/maria_zakourdaev/clip_image002_thumb_15EC89A1.jpg"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;When comparing native partitioning to a partitioned view, one of the greatest improvements is that using a partitioned table results in relatively small query plans. PVs in general had enormous query plans because each table in the view was a separate object with separate statistics. Due to the fact that natively partitioned tables are treated by the relational engine as a single object, fewer permutations are considered during the optimization phase, meaning a faster optimization time. Also, auto-parameterization doesn’t work with PVs because the rules of auto-parameterization are quite strict.&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:11pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;Adhoc SQL that uses a single partitioned table has many more opportunities to get auto-parameterized and produce a re-usable adhoc query plan.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:11pt;"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:11pt;"&gt;In PVs, tables are accessed sequentially.&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;When using native partitioning many operations can be done in parallel.&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:11pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;However, there are many challenges that we face when migrating from an environment that is using partitioned views to native partitioning. The usual way of upgrading such an environment is to create a new partitioned table and then to switch the data in, partition by partition. At some point in time, the old view and the new table flip flop names. During such an upgrade, from the user’s perspective, data is not available or even worse, partially available and the reports are not correct. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;After upgrade, maintenance tasks are also more cumbersome when performed against a partitioned table. Adding new indices to a huge table with thousands of millions of rows takes about 4 hours and the table is locked during this time. Same story with data type changes on columns. Also consider primary key changes when you need to drop the PK, which also takes about 3 hours and then add a new one – another 4 hours (a PK change is usually a bad thing anyway since it indicates the database design is not correct but we all know that it happens and sometimes we need to add an additional column to the PK). Also, there is no scale out for partitioned tables, meaning all partitions must reside on the same server on the same database.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;Here, surprisingly, our good old, unfairly forgotten, partitioning views can help us make our partitioning design even better. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;Consider the following scenario. You have a partitioned view with many big tables. Instead of switching the data partition by partition into a new table, you simply add the new partitioned table under the same partitioned view. No long Sch-M locks, no data partial availability and no downtime. All the new data is inserted into the new partitioned table. When the time comes, the old partitions get purged, leaving the partitioned view with only the native partitioned table underneath. If you need to support indices and other lengthy changes on metadata, you can simply add a new partition table to the view with the required metadata changes which means zero downtime to your environment. In case you need a distributed architecture across servers you also can do it using partitioned views.&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:11pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;span style="mso-no-proof:yes;"&gt;&lt;a href="http://sqlblog.com/blogs/maria_zakourdaev/clip_image004_0524DEF3.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image004" border="0" alt="clip_image004" width="576" height="426" src="http://sqlblog.com/blogs/maria_zakourdaev/clip_image004_thumb_18659592.jpg"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height:13pt;list-style-type:disc;margin-bottom:10pt;" class="MsoNormal" align="left"&gt;&lt;font face="Calibri"&gt;&lt;font style="font-size:11pt;"&gt;Native Partitioning is a great feature of SQL Server, but partitioned views can make it even better helping scaling out and performing maintenance tasks with zero downtime.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=41977" width="1" height="1"&gt;</content><author><name>Maria Zakourdaev</name><uri>http://www2.sqlblog.com/members/Maria+Zakourdaev.aspx</uri></author><category term="native partitioning" scheme="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/tags/native+partitioning/default.aspx" /><category term="partitioning views" scheme="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/tags/partitioning+views/default.aspx" /><category term="scaling out" scheme="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/tags/scaling+out/default.aspx" /></entry><entry><title>Write something awesome, no one sees it. Write something embarrassing, everyone sees it.</title><link rel="alternate" type="text/html" href="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/02/27/write-something-awesome-no-one-sees-it-write-something-embarrassing-everyone-sees-it.aspx" /><id>http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/2012/02/27/write-something-awesome-no-one-sees-it-write-something-embarrassing-everyone-sees-it.aspx</id><published>2012-02-27T15:52:00Z</published><updated>2012-02-27T15:52:00Z</updated><content type="html">&lt;p&gt;Hi everyone, &lt;/p&gt;  &lt;p&gt;I am truly exited to start blogging here among this incredible #sqlfamily.&lt;/p&gt;  &lt;p&gt;My name is Maria Zakourdaev. I have more than 10 years experience with SQL Server. The last five years have been spent mostly on benchmarking different SQL Server features and flows, like replication, data import, indexes impact on DML flows, star transformations in RDBMS, Hierarchic queries and custom OLAP-like aggregations. I was a speaker in the Microsoft Teched (Israel) on the SQL Server track. I am also an active member of the Israel SQL Server Group.&lt;/p&gt;  &lt;p&gt;Stay tuned&lt;/p&gt;  &lt;p&gt;Yours, Maria&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=41976" width="1" height="1"&gt;</content><author><name>Maria Zakourdaev</name><uri>http://www2.sqlblog.com/members/Maria+Zakourdaev.aspx</uri></author><category term="first blog" scheme="http://www2.sqlblog.com/blogs/maria_zakourdaev/archive/tags/first+blog/default.aspx" /></entry></feed>