MSFTScrptProdSamples Wiki & Documentation Rss Feedhttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=HomeMSFTScrptProdSamples Wiki Rss DescriptionUpdated Wiki: Homehttp://msftscrptprodsamples.codeplex.com/wikipage?version=27<div class="wikidoc"><a href="http://CodePlex.com/SqlServerSamples" class="externalLink">SQL Server Samples Portal Page<span class="externalLinkIcon"></span></a> &gt; SQL Server Scripts Product Samples<br /><br />This project contains Scripts samples released with Microsoft SQL Server product. Below is the list of these samples. If you are interested in contributing Scripts samples, please let us know by posting in the developers' forum.<br /><br />To download these samples click on the Releases tab (or click <a href="https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=MSFTScrptProdSamples" class="externalLink">here<span class="externalLinkIcon"></span></a>), optionally select another (older) release, then click on the Windows Installer package (MSI file) which matches the architecture of the installation computer.<br /><br />For information about how to use CodePlex to access SQL Server samples, click <a href="http://www.codeplex.com/SqlServerSamples/Wiki/View.aspx?title=HowToUseCodePlex&amp;referringTitle=Home" class="externalLink">here<span class="externalLinkIcon"></span></a>.<br />To download samples databases, click <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx" class="externalLink">here<span class="externalLinkIcon"></span></a> and then click the appropriate MSI file.<br />For release notes and brief descriptions of all the sample databases and code, including restrictions on SQL Express and Vista, click <a href="http://www.codeplex.com/SqlServerSamples/Wiki/View.aspx?title=SQLServerDatabasesandSamplesOverview&amp;referringTitle=Home" class="externalLink">here<span class="externalLinkIcon"></span></a>.<br /><br /><br /><table><tr><th> Sample </th><th> SQL Server 2005 </th><th> SQL Server 2008 &amp; SQL Server 2008R2 </th></tr>
<tr><td> Event Notifications Sample </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2005%21Event%20Notifications%20Sample&referringTitle=Home">SS2005</a> </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2008%21Event%20Notifications%20Sample&referringTitle=Home">SS2008</a> </td></tr>
<tr><td> AdventureWorksScripts </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2005%21Readme_AdventureWorksScripts&referringTitle=Home">SS2005</a> </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2008%21Readme_AdventureWorksScripts&referringTitle=Home">SS2008</a> </td></tr>
<tr><td> Alerts </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2005%21Readme_Alerts&referringTitle=Home">SS2005</a> </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2008%21Readme_Alerts&referringTitle=Home">SS2008</a> </td></tr>
<tr><td> FileGroups </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2005%21Readme_FileGroups&referringTitle=Home">SS2005</a> </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2008%21Readme_FileGroups&referringTitle=Home">SS2008</a> </td></tr>
<tr><td> PartitioningScript </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2005%21Readme_PartitioningScript&referringTitle=Home">SS2005</a> </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2008%21Readme_PartitioningScript&referringTitle=Home">SS2008</a> </td></tr>
<tr><td> SlidingWindow </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2005%21Readme_SlidingWindow&referringTitle=Home">SS2005</a> </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2008%21Readme_SlidingWindow&referringTitle=Home">SS2008</a> </td></tr>
<tr><td> Snapshot </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2005%21Readme_Snapshot&referringTitle=Home">SS2005</a> </td><td> <a href="http://msftscrptprodsamples.codeplex.com/wikipage?title=SS2008%21Readme_Snapshot&referringTitle=Home">SS2008</a> </td></tr></table><br /><br /><br /><b>Got questions? Want to contribute?</b> Check out the <a href="http://social.msdn.microsoft.com/Forums/en-us/sqlserversamples/threads" class="externalLink">SQL Server Community &amp; Samples Discussion Forum<span class="externalLinkIcon"></span></a>!<br /></div><div class="ClearBoth"></div>bonniefeWed, 09 Dec 2009 00:00:32 GMTUpdated Wiki: Home 20091209120032AUpdated Wiki: Homehttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=Home&version=26<div class="wikidoc">
<a href="http://CodePlex.com/SqlServerSamples" class="externalLink">SQL Server Samples Portal Page<span class="externalLinkIcon"></span></a> &gt; SQL Server Scripts Product Samples<br /> <br />This project contains Scripts samples released with Microsoft SQL Server product. Below is the list of these samples. If you are interested in contributing Scripts samples, please let us know by posting in the developers' forum.<br /> <br />To download these samples click on the Releases tab (or click <a href="https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=MSFTScrptProdSamples" class="externalLink">here<span class="externalLinkIcon"></span></a>), optionally select another (older) release, then click on the Windows Installer package (MSI file) which matches the architecture of the installation computer.<br /> <br />For information about how to use CodePlex to access SQL Server samples, click <a href="http://www.codeplex.com/SqlServerSamples/Wiki/View.aspx?title=HowToUseCodePlex&amp;referringTitle=Home" class="externalLink">here<span class="externalLinkIcon"></span></a>.<br />To download samples databases, click <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx" class="externalLink">here<span class="externalLinkIcon"></span></a> and then click the appropriate MSI file.<br />For release notes and brief descriptions of all the sample databases and code, including restrictions on SQL Express and Vista, click <a href="http://www.codeplex.com/SqlServerSamples/Wiki/View.aspx?title=SQLServerDatabasesandSamplesOverview&amp;referringTitle=Home" class="externalLink">here<span class="externalLinkIcon"></span></a>.<br /> <br /> <br /><table>
<tr>
<th> Sample </th><th> SQL Server 2005 </th><th> SQL Server 2008 </th>
</tr><tr>
<td> Event Notifications Sample </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Event%20Notifications%20Sample&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Event%20Notifications%20Sample&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> AdventureWorksScripts </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_AdventureWorksScripts&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_AdventureWorksScripts&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> Alerts </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_Alerts&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_Alerts&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> FileGroups </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_FileGroups&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_FileGroups&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> PartitioningScript </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_PartitioningScript&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_PartitioningScript&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> SlidingWindow </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_SlidingWindow&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_SlidingWindow&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> Snapshot </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_Snapshot&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_Snapshot&amp;referringTitle=Home">SS2008</a> </td>
</tr>
</table> <br /> <br /><b>Got questions? Want to contribute?</b> Check out the <a href="http://social.msdn.microsoft.com/Forums/en-us/sqlserversamples/threads" class="externalLink">SQL Server Community &amp; Samples Discussion Forum<span class="externalLinkIcon"></span></a>!<br />
</div>ReedMeThu, 29 Jan 2009 23:08:02 GMTUpdated Wiki: Home 20090129110802PUpdated Wiki: SS2008!Readme_Snapshothttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008!Readme_Snapshot&version=8<div class="wikidoc">
<h2>
Readme_Snapshot Sample
</h2> <br /> 11/05/2008 21:36:06<br /> <br /> <br /> This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. <br />The purpose of the <b>DatabaseSnapshot</b> sample is to demonstrate the database snapshot capabilities of SQL Server. For more information, see &quot;Database Snapshots&quot; in SQL Server Books Online. <br /> <br /><h3>
Scenario
</h3>A database snapshot is a read-only, static view of a database. This database is called the source database. Each database snapshot is transaction-consistent with the source database at the moment of the snapshot's creation. A snapshot persists until it is explicitly dropped by the database owner. Multiple snapshots can exist on a database. This sample creates a new database snapshot of the <b>AdventureWorks</b> sample database.<br /> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, perform the following tasks:<br /> <br /><ul>
<li> Install SQL Server and make sure you include the following components: </li><li> The Database Engine </li><li> SQL Server Management Studio </li><li> Download the <b>AdventureWorks</b> (OLTP) sample database and SQL Server Database Engine samples available at the Microsoft SQL Server <a href="http://go.microsoft.com/fwlink/?linkid=100108" class="externalLink">Samples and Community Projects Web site<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3> <br /><h6>
Installing and Running the Sample
</h6> <br /><ol>
<li>From Management Studio, open the file CreateDatabaseSnapshot.sql script located in the C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\DatabaseSnapshot\Scripts folder, and click <b>Execute</b>. &#169; 2008 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:50:22 GMTUpdated Wiki: SS2008!Readme_Snapshot 20081106115022PUpdated Wiki: SS2005!Readme_Snapshothttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005!Readme_Snapshot&version=15<div class="wikidoc">
<h2>
Readme_Snapshot
</h2> <br /> <br /> <br />The purpose of the <b>DatabaseSnapshot</b> sample is to demonstrate the database snapshot capabilities of Microsoft SQL Server 2005. For information about this new feature, refer to the topic, &quot;Database Snapshots&quot; in SQL Server Books Online. <br /> <br /><h3>
Scenario
</h3>A database snapshot is a read-only, static view of a database. This database is called the source database. Each database snapshot is transaction-consistent with the source database at the moment of the snapshot's creation. A snapshot persists until it is explicitly dropped by the database owner. Multiple snapshots can exist on a database. This sample creates a new database snapshot of the <b>AdventureWorks</b> sample database.<br /> <br /><h3>
Languages
</h3>Transact-SQL<br /> <br /><h3>
Prerequisites
</h3>Before running either of the scripts included in this sample, make sure the following software is installed:<br /> <br /><ul>
<li> SQL Server 2005, including the following components: </li><li> Database Engine </li><li> SQL Server Management Studio </li><li><b>AdventureWorks</b> (OLTP) sample database </li><li> SQL Server Engine samples </li>
</ul><h3>
Running the Sample
</h3> <br /><h6>
Installing and Running the Sample
</h6> <br /><ol>
<li>From SQL Server Management Studio, open the file <b>CreateDatabaseSnapshot.sql</b> script located in the C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\DatabaseSnapshot\Scripts folder, and click <b>Execute</b>. &#169; 2007 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:50:08 GMTUpdated Wiki: SS2005!Readme_Snapshot 20081106115008PUpdated Wiki: SS2008!Readme_SlidingWindowhttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008!Readme_SlidingWindow&version=8<div class="wikidoc">
<h2>
Readme_SlidingWindow Sample
</h2> <br /> 11/05/2008 21:36:06<br /> <br /> <br /> This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. <br />The purpose of the SlidingWindow sample is to demonstrate the ability to move partitions between tables by using the Transact-SQL ALTER TABLE SWITCH statement. For information about this feature, see &quot;Designing Partitions to Manage Subsets of Data&quot; in SQL Server Books Online.<br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications should not be connected to or used with your production SQL Server database without the permission of the system administrator. </td>
</tr>
</table> <br /> <br /> <br /><h3>
Scenarios
</h3>The sample moves the oldest month of data from the partitioned table <b>TransactionHistory</b> to the partitioned table <b>TransactionHistoryArchive</b>. Before running the partition switch, the partition function for <b>TransactionHistoryArchive</b> is modified to receive the new partition. Also a CHECK constraint is added to table <b>TransactionHistory</b>. Following the partition switch, both the <b>TransactionHistory</b> table and the <b>TransactionHistoryArchive</b> table are restored to a partitioning structure that would allow for a similar plan to run the following month.<br /> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, follow these steps.<br /> <br /><ol>
<li> Install SQL Server and make sure that you include the following components: </li><li> Database Engine </li><li> SQL Server Management Studio </li><li> Download the <b>AdventureWorks</b> (OLTP) sample database and SQL Server Database Engine samples available at the <a href="http://go.microsoft.com/fwlink/?linkid=100108" class="externalLink">Microsoft SQL Server Samples and Community Projects Web site<span class="externalLinkIcon"></span></a>. </li>
</ol><h3>
Running the Sample
</h3>The following procedure shows how to run the SlidingWindow sample. <br /> <br /><h6>
To run the SlidingWindow sample
</h6> <br /><ol>
<li>Run the PartitioningScript sample. For more information, see <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_PartitioningScript&amp;referringTitle=SS2008%21Readme_SlidingWindow">Readme_PartitioningScript Sample</a>.</li><li>In SQL Server Management Studio, open the file Sliding.sql. The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Engine\\Administration\SlidingWindow\Scripts, and then click <b>Execute</b>. &#169; 2008 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:49:54 GMTUpdated Wiki: SS2008!Readme_SlidingWindow 20081106114954PUpdated Wiki: SS2005!Readme_SlidingWindowhttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005!Readme_SlidingWindow&version=14<div class="wikidoc">
<h2>
Readme_SlidingWindow
</h2> <br /> <br /> <br />The purpose of the SlidingWindow sample is to demonstrate the ability to move partitions between tables by using the Transact-SQL ALTER TABLE SWITCH statement. For information about this feature, see &quot;Designing Partitions to Manage Subsets of Data&quot; in SQL Server Books Online.<br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications should not be connected to or used with your production SQL Server database without the permission of the system administrator. </td>
</tr>
</table> <br /> <br /> <br /><h3>
Scenarios
</h3>The sample moves the oldest month of data from the partitioned table <b>TransactionHistory</b> to the partitioned table <b>TransactionHistoryArchive</b>. Before running the partition switch, the partition function for <b>TransactionHistoryArchive</b> is modified to receive the new partition. Also a CHECK constraint is added to table <b>TransactionHistory</b>. Following the partition switch, both the <b>TransactionHistory</b> table and the <b>TransactionHistoryArchive</b> table are restored to a partitioning structure that would allow for a similar plan to run the following month.<br /> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, install SQL Server 2005 and make sure you include the following components:<br /> <br /><ul>
<li> Database Engine </li><li> SQL Server Management Studio </li><li><b>AdventureWorks</b> (OLTP) sample database which is included with SQL Server 2005, and is also available at the <a href="http://go.microsoft.com/fwlink/?linkid=62796" class="externalLink">Microsoft SQL Server Developer Center<span class="externalLinkIcon"></span></a>. </li><li> SQL Server Database Engine samples. These samples are included with SQL Server 2005. You can download the latest version of the samples at the <a href="http://go.microsoft.com/fwlink/?linkid=62796" class="externalLink">Microsoft SQL Server Developer Center<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to run the SlidingWindow sample. <br /> <br /><h6>
To run the SlidingWindow sample
</h6> <br /><ol>
<li>Run the PartitioningScript sample. For more information, see <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_PartitioningScript&amp;referringTitle=SS2005%21Readme_SlidingWindow">Readme_PartitioningScript</a>.</li><li>In SQL Server Management Studio, open the file Sliding.sql. The default installation directory is C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\SlidingWindow\Scripts, and then click <b>Execute</b>. &#169; 2007 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:49:40 GMTUpdated Wiki: SS2005!Readme_SlidingWindow 20081106114940PUpdated Wiki: SS2008!Readme_PartitioningScripthttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008!Readme_PartitioningScript&version=9<div class="wikidoc">
<h2>
Readme_PartitioningScript Sample
</h2> <br /> 11/05/2008 21:36:06<br /> <br /> <br /> This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. <br />The purpose of the PartitioningScript sample is to demonstrate the table and index partitioning capabilities of SQL Server. For information about this feature, see &quot;Partitioned Tables and Indexes&quot; in SQL Server Books Online.<br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications should not be connected to or used with your production SQL Server database without the permission of the system administrator. </td>
</tr>
</table> <br /> <br /> <br /><h3>
Scenario
</h3>In the <b>AdventureWorks</b> sample database, the <b>TransactionHistory</b> table is used to record each sales order, purchase order, and work order transaction. Therefore, this table is one of the largest and most heavily accessed tables in the database. The <b>TransactionHistoryArchive</b> table was created to store older transactions from the <b>TransactionHistory</b> table. Data is transferred to <b>TransactionHistoryArchive</b> on a monthly basis for additional analysis enabling <b>TransactionHistory</b> to stay reasonably small and maintain current data only. <br />To create the partitions for these tables, the sample performs these operations:<br /> <br /><ul>
<li> Creates partition function <b>TransactionRangePF1</b> on the <b>TransactionDate</b> column of the <b>TransactionHistory</b> table, so that each partition contains one month of data. </li><li> Creates partition scheme <b>TransactionsPS1</b> to map the partitions to filegroups. In this sample, all partitions reside on the same filegroup. </li><li> Drops and re-creates the <b>TransactionHistory</b> table specifying the partition scheme <b>TransactionsPS1</b> as the location for the table. </li><li> Creates partition function <b>TransactionRangePF2</b> on the <b>TransactionDate</b> column of the <b>TransactionHistoryArchive</b> table. </li><li> Creates partition scheme <b>TransactionsPS2</b> to map the partitions to filegroups. In this sample, all partitions reside on the same filegroup. </li><li> Drops and re-creates the <b>TransactionHistoryArchive</b> table specifying the partition scheme <b>TransactionsPS2</b> as the location for the table. </li><li> Bulk inserts data into the two tables. The transfer of monthly &quot;chunks&quot; of data between the tables is performed by switching partitions between the two tables. This typically takes just seconds, instead of minutes or hours in earlier releases, because it is a metadata operation only instead of a physical relocation of the data. Partition switching is demonstrated in the SlidingWindow sample. </li>
</ul> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, perform the following tasks:<br /> <br /><ul>
<li> Install SQL Server and make sure you include the following components: </li><li> Database Engine </li><li> SQL Server Management Studio </li><li> Download the <b>AdventureWorks</b> (OLTP) sample database and Database Engine samples available at the <a href="http://go.microsoft.com/fwlink/?linkid=100108" class="externalLink">Microsoft SQL Server Samples and Community Projects Web site<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to run the PartitioningScript sample. <br /> <br /><h6>
To run the PartitioningScript sample
</h6> <br /><ol>
<li>In SQL Server Management Studio, open the file PartitionAW.sql. The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Engine\\Administration\Partitioning\Scripts. Click <b>Execute</b>. &#169; 2008 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:49:26 GMTUpdated Wiki: SS2008!Readme_PartitioningScript 20081106114926PUpdated Wiki: SS2005!Readme_PartitioningScripthttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005!Readme_PartitioningScript&version=14<div class="wikidoc">
<h2>
Readme_PartitioningScript
</h2> <br /> <br /> <br />The purpose of the PartitioningScript sample is to demonstrate the table and index partitioning capabilities of SQL Server 2005. For information about this new feature, see &quot;Partitioned Tables and Indexes&quot; in SQL Server Books Online. <br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications should not be connected to or used with your production SQL Server database without the permission of the system administrator. </td>
</tr>
</table> <br /> <br /> <br /><h3>
Scenario
</h3>In the <b>AdventureWorks</b> sample database, the <b>TransactionHistory</b> table is used to record each sales order, purchase order, and work order transaction. Therefore, this table is one of the largest and most heavily accessed tables in the database. The <b>TransactionHistoryArchive</b> table was created to store older transactions from the <b>TransactionHistory</b> table. Data is transferred to <b>TransactionHistoryArchive</b> on a monthly basis for additional analysis enabling <b>TransactionHistory</b> to stay reasonably small and maintain current data only. <br />To create the partitions for these tables, the sample performs these operations:<br /> <br /><ul>
<li> Creates partition function <b>TransactionRangePF1</b> on the <b>TransactionDate</b> column of the <b>TransactionHistory</b> table, so that each partition contains one month of data. </li><li> Creates partition scheme <b>TransactionsPS1</b> to map the partitions to filegroups. In this sample, all partitions reside on the same filegroup. </li><li> Drops and re-creates the <b>TransactionHistory</b> table specifying the partition scheme <b>TransactionsPS1</b> as the location for the table. </li><li> Creates partition function <b>TransactionRangePF2</b> on the <b>TransactionDate</b> column of the <b>TransactionHistoryArchive</b> table. </li><li> Creates partition scheme <b>TransactionsPS2</b> to map the partitions to filegroups. In this sample, all partitions reside on the same filegroup. </li><li> Drops and re-creates the <b>TransactionHistoryArchive</b> table specifying the partition scheme <b>TransactionsPS2</b> as the location for the table. </li><li> Bulk inserts data into the two tables. The transfer of monthly &quot;chunks&quot; of data between the tables is performed by switching partitions between the two tables. This typically takes just seconds, instead of minutes or hours in earlier releases, because it is a metadata operation only instead of a physical relocation of the data. Partition switching is demonstrated in the SlidingWindow sample. </li>
</ul> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, install SQL Server 2005 and make sure you include the following components:<br /> <br /><ul>
<li> Database Engine </li><li> SQL Server Management Studio </li><li><b>AdventureWorks</b> (OLTP) sample database which is included with SQL Server 2005, and is also available at the <a href="http://go.microsoft.com/fwlink/?linkid=62796" class="externalLink">Microsoft SQL Server Developer Center<span class="externalLinkIcon"></span></a>. </li><li> SQL Server Database Engine samples. These samples are included with SQL Server 2005. You can download the latest version of the samples at the <a href="http://go.microsoft.com/fwlink/?linkid=62796" class="externalLink">Microsoft SQL Server Developer Center<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to run the PartitioningScript sample. <br /> <br /><h6>
To run the PartitioningScript sample
</h6> <br /><ol>
<li>In SQL Server Management Studio, open the file PartitionAW.sql. The default installation directory is C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\Partitioning\Scripts, and then click <b>Execute</b>. &#169; 2007 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:49:10 GMTUpdated Wiki: SS2005!Readme_PartitioningScript 20081106114910PUpdated Wiki: SS2008!Readme_FileGroupshttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008!Readme_FileGroups&version=9<div class="wikidoc">
<h2>
Readme_FileGroups Sample
</h2> <br /> 11/05/2008 21:36:06<br /> <br /> <br /> This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. <br />The purpose of this sample is to demonstrate filegroup and file capabilities in SQL Server. For more information, see &quot;Designing Files and Filegroups&quot; in SQL Server Books Online.<br /> <br /><h3>
Scenario
</h3>Filegroups allow files to be grouped together for administrative and data allocation/placement purposes. For example, filegroups allow placement of objects on specific physical disks, which can improve performance due to parallel disk I/O searching. Also, files and filegroups can be backed up and restored individually, which can increase the speed of recovery by allowing you to restore only damaged files without restoring the rest of the database. <br />This sample creates:<br /> <br /><ul>
<li> The <b>WorkOrderGroup</b> filegroup and the data file <b>WorkOrders</b> and then moves the <b>Production.WorkOrder</b> and <b>Production.WorkOrderRouting</b> tables to that filegroup in the <b>AdventureWorks</b> sample database. </li><li> The <b>TransactionHistoryGroup</b> filegroup and data file <b>TransactionHistory</b> and then moves the <b>TransactionHistory</b> and <b>TransactionHistoryArchive</b> tables to that filegroup in the <b>AdventureWorks</b> sample database. </li>
</ul><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, perform the following tasks:<br /> <br /><ul>
<li> Install SQL Server and make sure you include the following components: </li><li> The Database Engine </li><li> SQL Server Management Studio </li><li> Download the <b>AdventureWorks</b> (OLTP) sample database and Database Engine samples available at the <a href="http://go.microsoft.com/fwlink/?linkid=100108" class="externalLink">Microsoft SQL Server Samples and Community Projects Web site<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to run the CreateFileGroups.sql Transact-SQL script that creates files and filegroups in the <b>AdventureWorks</b> sample database.<br /> <br /><h6>
Running the CreateFilegroups Sample
</h6> <br /><ol>
<li>From SQL Server Management Studio, open the file CreateFileGroups.sql, located in the C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\FileGroups folder, and click <b>Execute</b>. &#169; 2008 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:48:56 GMTUpdated Wiki: SS2008!Readme_FileGroups 20081106114856PUpdated Wiki: SS2005!Readme_FileGroupshttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005!Readme_FileGroups&version=15<div class="wikidoc">
<h2>
Readme_FileGroups
</h2> <br /> <br /> <br />The purpose of this sample is to demonstrate filegroup and file capabilities in Microsoft SQL Server 2005. For information about this feature, refer to the topic, &quot;Designing Files and Filegroups&quot; in SQL Server Books Online.<br /> <br /><h3>
Scenario
</h3>Filegroups allow files to be grouped together for administrative and data allocation/placement purposes. For example, filegroups allow placement of objects on specific physical disks, which can improve performance due to parallel disk I/O searching. Also, files and filegroups can be backed up and restored individually, which can increase the speed of recovery by allowing you to restore only damaged files without restoring the rest of the database. <br />This sample creates:<br /> <br /><ul>
<li> The <b>WorkOrderGroup</b> filegroup and the data file <b>WorkOrders</b> and then moves the <b>Production.WorkOrder</b> and <b>Production.WorkOrderRouting</b> tables to that filegroup in the <b>AdventureWorks</b> sample database. </li><li> The <b>TransactionHistoryGroup</b> filegroup and data file <b>TransactionHistory</b> and then moves the <b>TransactionHistory</b> and <b>TransactionHistoryArchive</b> tables to that filegroup in the <b>AdventureWorks</b> sample database. </li>
</ul><h3>
Languages
</h3>Transact-SQL<br /> <br /><h3>
Prerequisites
</h3>Before running the sample, make sure the following software is installed:<br /> <br />* <br /> SQL Server 2005, including the following components: <br /><ul>
<li> Database Engine </li><li> SQL Server Management Studio </li><li><b>AdventureWorks</b> (OLTP) sample database </li><li> SQL Server Engine samples </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to run the <b>CreateFileGroups.sql</b> Transact-SQL script that creates files and filegroups in the <b>AdventureWorks</b> sample database.<br /> <br /><h6>
Running the CreateFilegroups Sample
</h6> <br /><ol>
<li>From SQL Server Management Studio, open the file <b>CreateFileGroups.sql</b> script located in the C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\FileGroups\Scripts folder, and click <b>Execute</b>. &#169; 2007 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:48:40 GMTUpdated Wiki: SS2005!Readme_FileGroups 20081106114840PUpdated Wiki: SS2008!Readme_Alertshttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008!Readme_Alerts&version=9<div class="wikidoc">
<h2>
Readme_Alerts Sample
</h2> <br /> 11/05/2008 21:36:06<br /> <br /> <br /> This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. <br />The purpose of the Alerts sample is to demonstrate the alert capabilities of SQL Server. For more information, see &quot;Defining Alerts&quot; in SQL Server Books Online. <br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator. </td>
</tr>
</table> <br /> <br /> <br /><h3>
Scenario
</h3>This sample script file creates SQL Server Agent alerts in SQL Server.<br />After the execution of this script you will find new alerts added to the alerts collection. You can examine them in SQL Server Management Studio or by calling sp_help_alert stored procedure.<br /> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, perform the following tasks:<br /> <br /><ul>
<li> Install SQL Server and make sure you include the following components: </li><li> The Database Engine </li><li> SQL Server Management Studio </li><li> Download the <b>AdventureWorks</b> (OLTP) sample database and Database Engine samples available at the <a href="http://go.microsoft.com/fwlink/?linkid=100108" class="externalLink">Microsoft SQL Server Samples and Community Projects Web site<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to run the Alerts sample.<br /> <br /><h6>
Running the Alerts Sample
</h6> <br /><ol>
<li>From Management Studio, open the agent<i>sample</i>alerts.sql script. The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\Alerts\Scripts.</li><li>Click <b>Execute</b>. &#169; 2008 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:48:25 GMTUpdated Wiki: SS2008!Readme_Alerts 20081106114825PUpdated Wiki: SS2005!Readme_Alertshttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005!Readme_Alerts&version=15<div class="wikidoc">
<h2>
Readme_Alerts
</h2> <br /> <br /> <br />The purpose of the <b>Alerts</b> sample is to demonstrate the alert capabilities of Microsoft SQL Server 2005. For information about this new feature, refer to the topic, &quot;Defining Alerts&quot; in SQL Server Books Online. <br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications should not be connected to or used with your production SQL Server database without the permission of the system administrator. </td>
</tr>
</table> <br /> <br /> <br /><h3>
Scenario
</h3>This sample script file creates SQL Agent alerts in Microsoft SQL Server 2005.<br />After the execution of this script you will find new alerts added to the alerts collection. You could examine them in Management Studio or by calling sp<i>help</i>alert stored procedure.<br /> <br /><h3>
Languages
</h3>Transact-SQL<br /> <br /><h3>
Prerequisites
</h3>Before running this sample, make sure the following software is installed:<br /> <br /><ul>
<li> SQL Server 2005, including the following components: </li><li> Database Engine </li><li> SQL Server Management Studio </li><li> SQL Server Engine samples </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to run the <b>Alerts</b> sample. <br /> <br /><h6>
Running the Alerts Sample
</h6> <br /><ol>
<li>From SQL Server Management Studio, open the <b>agent<i>sample</i>alerts.sql</b> script. The default installation directory is <i>drive</i>:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\Alerts\Scripts.</li><li>Click <b>Execute</b>. &#169; 2007 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:48:09 GMTUpdated Wiki: SS2005!Readme_Alerts 20081106114809PUpdated Wiki: SS2008!Readme_AdventureWorksScriptshttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008!Readme_AdventureWorksScripts&version=9<div class="wikidoc">
<h2>
Readme_AdventureWorksScripts Sample
</h2> <br /> 11/05/2008 21:36:06<br /> <br /> <br /> This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. <br />In SQL Server, scripts are available in SQLServerEngineSamples.msi that provide two alternatives to using the schemas in the <b>AdventureWorks</b> sample database. <br /> <br /><h3>
Scenario
</h3>In SQL Server, tables and other schema-scoped objects are contained in schemas, and the schemas are owned by users. In <b>AdventureWorks</b>, five schemas are used to contain schema-scoped objects that are based on business functionality. For example, customer and sales-related objects are contained in the <b>Sales</b> schema; employee-related objects are contained in the <b>HumanResources</b> schema, and so on. For more information, see &quot;Schemas in AdventureWorks&quot; in SQL Server Books Online.<br />The addition of schemas introduces changes to the way in which you access tables and other schema-scoped objects. To access objects in a schema other than the default schema (<b>DB</b>), at a minimum, a two-part identifier in the form <i>schema</i>name<i><b>.</b></i>object<i>name</i> must be specified. This is true for all DDL and DML statements that reference schema-scoped objects.<br />The scripts included in this sample provide alternatives to working with schema-scoped objects. One alternative transfers all schema-scoped objects to the <b>dbo</b> schema and the other creates synonyms for each schema-scoped object in the <b>dbo</b> schema. <br /> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Features
</h3>The <b>AdventureWorks</b> scripts use the following features of the Database Engine.<br /> <br /><table>
<tr>
<th> Application area </th><th> Features </th>
</tr><tr>
<td> Database Engine </td><td> Schema DDL </td>
</tr><tr>
<td> Database Engine </td><td> Synonyms </td>
</tr>
</table> <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, perform the following tasks:<br /> <br /><ul>
<li> Install SQL Server and make sure you include the following components: </li><li> The Database Engine </li><li> SQL Server Management Studio</li>
</ul> <br /><ul>
<li> Download the <b>AdventureWorks</b> (OLTP) sample database and Database Engine samples available at the <a href="http://go.microsoft.com/fwlink/?linkid=100108" class="externalLink">Microsoft SQL Server Samples and Community Projects Web site<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Transferring Objects to the dbo Schema
</h3>The AlterSchemaToDbo.sql script transfers every schema-scoped object in <b>AdventureWorks</b> to the <b>dbo</b> schema. After this script has been run, users who have a default schema of <b>dbo</b> will not have to use a two-part identifier when they reference these objects in DDL and DML statements.<br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> The code examples and samples provided with SQL Server will not run after the AlterSchemaToDbo.sql is executed unless the schema names specified in the code are replaced with <b>dbo</b> or removed. </td>
</tr>
</table> <br /> <br />The AlterSchemaFromDbo.sql script transfers (returns) the objects from the <b>dbo</b> schema to the schemas they were in before running the AlterSchemaToDbo.sql script.<br /> <br /><h5>
Running the Scripts to Transfer Objects to and from the dbo Schema
</h5>The following procedure shows how to run the Transact-SQL script that transfers <b>AdventureWorks</b> schema-scoped objects to the <b>dbo</b> schema. <br /> <br /><h6>
To run the AlterSchemaToDbo script
</h6> <br /><ul>
<li>In SQL Server Management Studio, open the file AlterSchemaToDbo.sql script located in the C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\AdventureWorks\Scripts folder, and then click <b>Execute</b>.The following procedure shows how to run the Transact-SQL script that returns <b>AdventureWorks</b> schema-scoped objects from the <b>dbo</b> schema to their original schemas. </li>
</ul> <br /><h6>
To run the AlterSchemaFromDbo scripts
</h6> <br /><ul>
<li>In SQL Server Management Studio, open the file AlterSchemaFromDbo.sql script located in the C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\AdventureWorks\Scripts folder, and then click <b>Execute</b>.</li>
</ul><h3>
Using Synonyms
</h3>A synonym is an alternative name given to a schema-scoped object. The synonym is specified instead of the base object in DDL and DML statements. <br />The CreateSynonymsDbo.sql script creates a synonym for each schema-scoped object in <b>AdventureWorks</b>. The synonym name is the same as the base object name, but uses the <b>dbo</b> schema. For example, the synonym for *HumanResources.Department *is <b>dbo.Department</b>. <br />Using synonyms has the following advantages:<br /> <br />* <br /> If <b>dbo</b> is the default schema, a two-part identifier is not needed to specify these objects in DDL and DML statements. <br /><ul>
<li> The code examples and samples provided with SQL Server can be used without modification. The DropSynonymsDbo.sql script drops the synonyms that are created by the CreateSynonymsDbo.sql script. </li>
</ul> <br /><h5>
Running the Synonym Scripts
</h5>The following procedure shows how to run the Transact-SQL script that creates synonyms in the <b>dbo</b> schema for each <b>AdventureWorks</b> schema-scoped object. <br /> <br /><h6>
To run the CreateSynonymsDbo script
</h6> <br /><ul>
<li>In SQL Server Management Studio, open the file CreateSynonymsDbo.sql script located in the C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\AdventureWorks\Scripts folder, and then click <b>Execute</b>.The following procedure shows how to run the Transact-SQL script that removes the synonyms that are created by the CreateSynonymsDbo.sql script from the database. </li>
</ul> <br /><h6>
To run the DropSynonymsDbo script
</h6> <br /><ul>
<li>In SQL Server Management Studio, open the file DropSynonymsDbo.sql script located in the C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\AdventureWorks\Scripts folder, and then click <b>Execute</b>.</li>
</ul><h3>
Removing the Scripts
</h3>Use the following procedure to remove one or more scripts that are included in this sample.<br /> <br /><h6>
To remove the scripts
</h6> <br /><ul>
<li>In Windows Explorer, locate the C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\AdventureWorks\Scripts folder, right-click the script name and click <b>Delete</b>. &#169; 2008 Microsoft Corporation. All rights reserved.</li>
</ul>
</div>bonniefeThu, 06 Nov 2008 23:47:55 GMTUpdated Wiki: SS2008!Readme_AdventureWorksScripts 20081106114755PUpdated Wiki: SS2005!Readme_AdventureWorksScriptshttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005!Readme_AdventureWorksScripts&version=15<div class="wikidoc">
<h2>
Readme_AdventureWorksScripts
</h2> <br /> <br /> <br />In Microsoft SQL Server 2005, scripts are available in SQLServerEngineSamples.msi that provide two alternatives to using the schemas in the <b>AdventureWorks</b> sample database. <br /> <br /><h3>
Scenario
</h3>In SQL Server 2005, tables and other schema-scoped objects are contained in schemas, and the schemas are owned by users. In <b>AdventureWorks</b> , five schemas are used to contain schema-scoped objects that are based on business functionality. For example, customer and sales-related objects are contained in the <b>Sales</b> schema; employee-related objects are contained in the <b>HumanResources</b> schema, and so on. For more information, see &quot;Schemas in AdventureWorks&quot; in SQL Server Books Online.<br />The addition of schemas introduces changes to the way in which you access tables and other schema-scoped objects. To access objects in a schema other than the default schema (<b>DB</b>), at a minimum, a two-part identifier in the form <i>schema</i>name<i><b>.</b></i>object<i>name</i> must be specified. This is true for all DDL and DML statements that reference schema-scoped objects.<br />The scripts included in this sample provide alternatives to working with schema-scoped objects. One alternative transfers all schema-scoped objects to the <b>dbo</b> schema and the other creates synonyms for each schema-scoped object in the <b>dbo</b> schema. <br /> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Features
</h3>The <b>AdventureWorks</b> scripts use the following features of the SQL Server 2005 Database Engine.<br /> <br /><table>
<tr>
<th> Application area </th><th> Features </th>
</tr><tr>
<td> Database Engine </td><td> Schema DDL </td>
</tr><tr>
<td> Database Engine </td><td> Synonyms </td>
</tr>
</table> <br /> <br /><h3>
Prerequisites
</h3>Before you run either of the scripts included in this sample, install SQL Server 2005 and make sure you include the following components:<br /> <br /><ul>
<li> Database Engine </li><li> SQL Server Management Studio </li><li> The AdventureWorks database which is included with SQL Server 2005, and is also available at the SQL Server Developer <a href="http://go.microsoft.com/fwlink/?linkid=62796" class="externalLink">Web site<span class="externalLinkIcon"></span></a>. </li><li> The SQL Server 2005 Database Engine samples. These samples are included with SQL Server 2005. You can download the latest version of the samples at the SQL Server Developer <a href="http://go.microsoft.com/fwlink/?linkid=62796" class="externalLink">Web site<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Transferring Objects to the dbo Schema
</h3>The AlterSchemaToDbo.sql script transfers every schema-scoped object in <b>AdventureWorks</b> to the <b>dbo</b> schema. After this script has been run, users who have a default schema of <b>dbo</b> will not have to use a two-part identifier when they reference these objects in DDL and DML statements.<br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> The code examples and samples provided with SQL Server 2005 will not run after the AlterSchemaToDbo.sql is executed unless the schema names specified in the code are replaced with <b>dbo</b> or removed. </td>
</tr>
</table> <br /> <br />The AlterSchemaFromDbo.sql script transfers (returns) the objects from the <b>dbo</b> schema to the schemas they were in before running the AlterSchemaToDbo.sql script.<br /> <br /><h5>
Running the Scripts to Transfer Objects to and from the dbo Schema
</h5>The following procedure shows how to run the Transact-SQL script that transfers <b>AdventureWorks</b> schema-scoped objects to the <b>dbo</b> schema. <br /> <br /><h6>
To run the AlterSchemaToDbo script
</h6> <br /><ul>
<li>In SQL Server Management Studio, open the file AlterSchemaToDbo.sql script located in the C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\AdventureWorks\Scripts folder, and then click <b>Execute</b>.The following procedure shows how to run the Transact-SQL script that returns <b>AdventureWorks</b> schema-scoped objects from the <b>dbo</b> schema to their original schemas. </li>
</ul> <br /><h6>
To run the AlterSchemaFromDbo scripts
</h6> <br /><ul>
<li>In SQL Server Management Studio, open the file AlterSchemaFromDbo.sql script located in the C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\AdventureWorks\Scripts folder, and then click <b>Execute</b>.</li>
</ul><h3>
Using Synonyms
</h3>A synonym is an alternative name given to a schema-scoped object. The synonym is specified instead of the base object in DDL and DML statements. <br />The CreateSynonymsDbo.sql script creates a synonym for each schema-scoped object in <b>AdventureWorks</b> . The synonym name is the same as the base object name, but uses the <b>dbo</b> schema. For example, the synonym for *HumanResources.Department *is <b>dbo.Department</b>. <br />Using synonyms has the following advantages:<br /> <br /><ul>
<li> If <b>dbo</b> is the default schema, a two-part identifier is not needed to specify these objects in DDL and DML statements. </li><li> The code examples and samples provided with SQL Server 2005 can be used without modification. The DropSynonymsDbo.sql script drops the synonyms that are created by the CreateSynonymsDbo.sql script. </li>
</ul> <br /><h5>
Running the Synonym Scripts
</h5>The following procedure shows how to run the Transact-SQL script that creates synonyms in the <b>dbo</b> schema for each <b>AdventureWorks</b> schema-scoped object. <br /> <br /><h6>
To run the CreateSynonymsDbo script
</h6> <br /><ul>
<li>In SQL Server Management Studio, open the file CreateSynonymsDbo.sql script located in the C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\AdventureWorks\Scripts folder, and then click <b>Execute</b>.The following procedure shows how to run the Transact-SQL script that removes the synonyms that are created by the CreateSynonymsDbo.sql script from the database. </li>
</ul> <br /><h6>
To run the DropSynonymsDbo script
</h6> <br /><ul>
<li>In SQL Server Management Studio, open the file DropSynonymsDbo.sql script located in the C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\AdventureWorks\Scripts folder, and then click <b>Execute</b>.</li>
</ul><h3>
Removing the Scripts
</h3>Use the following procedure to remove one or more scripts that are included in this sample.<br /> <br /><h6>
To remove the scripts
</h6> <br /><ul>
<li>In Windows Explorer, locate the C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\AdventureWorks\Scripts folder, right-click the script name and click <b>Delete</b>. &#169; 2007 Microsoft Corporation. All rights reserved.</li>
</ul>
</div>bonniefeThu, 06 Nov 2008 23:47:39 GMTUpdated Wiki: SS2005!Readme_AdventureWorksScripts 20081106114739PUpdated Wiki: SS2008!Event Notifications Samplehttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008!Event Notifications Sample&version=9<div class="wikidoc">
<h2>
Readme_Event Notifications Sample
</h2> <br /> 11/05/2008 21:36:06<br /> <br /> <br /> This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. <br />The event notification sample (EventNotificationSample.sql) provides an example of how event notifications can be used in an OLTP database application. For more information, see <b>Event Notifications (Database Engine)</b>. <br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications should not be connected to or used with your production SQL Server database without the permission of the system administrator. </td>
</tr>
</table> <br /> <br /> <br /><h3>
Scenario
</h3>Event notifications can be used to monitor and respond to database activity. EventNotificationSample.sql monitors the following kinds of events: <br /> <br /><ul>
<li><b>CreateDatabaseNotification</b> event notification monitors when databases are created and dropped on the server instance. </li><li><b>AuditLoginLogoutNotification</b> event notification monitors when logins, logouts, and failed logins occur on the server instance. The event notifications send XML data about these events to the Microsoft Service Broker service specified in the sample. The sample also defines a queue to receive the messages and a route that specifies the service address; in this case, the address is the local database. A WAITFOR clause, which is enclosed in commenting characters, instructs the server to wait 60 seconds until the service receives the message and casts it as <b>XML</b>. Additional scripts, which are also enclosed in commenting characters, test the event notifications by causing the events on which they are created to occur on the server instance.</li>
</ul> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, follow these steps:<br /> <br /><ul>
<li> Install SQL Server and make sure that you include the following components: </li><li> Database Engine </li><li> SQL Server Management Studio </li><li> Download the <b>AdventureWorks</b> (OLTP) sample database and Database Engine samples available at the <a href="http://go.microsoft.com/fwlink/?linkid=100108" class="externalLink">Microsoft SQL Server Samples and Community Projects Web site<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to install and run the event notification sample. <br /> <br /><h6>
To run the event notification sample
</h6> <br /><ol>
<li>From SQL Server Management Studio, open EventNotificationSample.sql. The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Engine\\Administration\EventNotifications\Scripts\.</li><li>Click <b>Execute</b>. &#169; 2008 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:47:22 GMTUpdated Wiki: SS2008!Event Notifications Sample 20081106114722PUpdated Wiki: SS2005!Event Notifications Samplehttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005!Event Notifications Sample&version=15<div class="wikidoc">
<h2>
Event Notifications Sample
</h2> <br /> <br /> <br />The event notification sample (EventNotificationSample.sql) provides an example of how event notifications can be used in an OLTP database application. For more information, see <b>Event Notifications (Database Engine)</b>. <br /> <br /><table>
<tr>
<th> Important: </th>
</tr><tr>
<td> Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications should not be connected to or used with your production SQL Server database without the permission of the system administrator. </td>
</tr>
</table> <br /> <br /> <br /><h3>
Scenario
</h3>Event notifications can be used to monitor and respond to database activity. EventNotificationSample.sql monitors the following kinds of events: <br /> <br /><ul>
<li><b>CreateDatabaseNotification</b> event notification monitors when databases are created and dropped on the server instance. </li><li><b>AuditLoginLogoutNotification</b> event notification monitors when logins, logouts, and failed logins occur on the server instance. The event notifications send XML data about these events to the Microsoft SQL Server 2005 Service Broker service specified in the sample. The sample also defines a queue to receive the messages and a route that specifies the service address; in this case, the address is the local database. A WAITFOR clause, which is enclosed in commenting characters, instructs the server to wait 60 seconds until the service receives the message and casts it as <b>xml</b>. Additional scripts, which are also enclosed in commenting characters, test the event notifications by causing the events on which they are created to occur on the server instance.</li>
</ul> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before running this sample, make sure the following software is installed:<br /> <br /><ul>
<li> Microsoft SQL Server 2005 with the following components: </li><li> SQL Server 2005 Database Engine </li><li> SQL Server Management Studio </li><li> AdventureWorks (OLTP) sample database which is included with SQL Server 2005, and is also available at the <a href="http://go.microsoft.com/fwlink/?linkid=62796" class="externalLink">Microsoft SQL Server Developer Center<span class="externalLinkIcon"></span></a>. </li><li> SQL Server Database Engine samples (SQLServerSample.msi). These samples are included with SQL Server 2005. You can download the latest version of the samples at the <a href="http://go.microsoft.com/fwlink/?linkid=62796" class="externalLink">Microsoft SQL Server Developer Center<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3>The following procedure shows how to install and run the event notification sample. <br /> <br /><h6>
To run the event notification sample
</h6> <br /><ol>
<li>From SQL Server Management Studio, open EventNotificationSample.sql. The default installation directory is C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\EventNotifications\Scripts\.</li><li>Click <b>Execute</b>. &#169; 2007 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 06 Nov 2008 23:47:08 GMTUpdated Wiki: SS2005!Event Notifications Sample 20081106114708PUpdated Wiki: Homehttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=Home&version=25<div class="wikidoc">
<a href="http://CodePlex.com/SqlServerSamples" class="externalLink">SQL Server Samples Portal Page<span class="externalLinkIcon"></span></a> &gt; SQL Server Scripts Product Samples<br /> <br />This project contains Scripts samples released with Microsoft SQL Server product. Below is the list of these samples. If you are interested in contributing Scripts samples, please let us know by posting in the developers' forum.<br /> <br />To download these samples click on the Releases tab (or click <a href="https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=MSFTScrptProdSamples" class="externalLink">here<span class="externalLinkIcon"></span></a>), optionally select another (older) release, then click on the Windows Installer package (MSI file) which matches the architecture of the installation computer.<br /> <br />For information about how to use CodePlex to access SQL Server samples, click <a href="http://www.codeplex.com/SqlServerSamples/Wiki/View.aspx?title=HowToUseCodePlex&amp;referringTitle=Home" class="externalLink">here<span class="externalLinkIcon"></span></a>.<br />To download samples databases, click <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx" class="externalLink">here<span class="externalLinkIcon"></span></a> and then click the appropriate MSI file.<br />For release notes and brief descriptions of all the sample databases and code, including restrictions on SQL Express and Vista, click <a href="http://www.codeplex.com/SqlServerSamples/Wiki/View.aspx?title=SQLServerDatabasesandSamplesOverview&amp;referringTitle=Home" class="externalLink">here<span class="externalLinkIcon"></span></a>.<br /> <br /> <br /><table>
<tr>
<th> Sample </th><th> SQL Server 2005 </th><th> SQL Server 2008 </th>
</tr><tr>
<td> Event Notifications Sample </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Event%20Notifications%20Sample&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Event%20Notifications%20Sample&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> AdventureWorksScripts </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_AdventureWorksScripts&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_AdventureWorksScripts&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> Alerts </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_Alerts&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_Alerts&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> FileGroups </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_FileGroups&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_FileGroups&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> PartitioningScript </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_PartitioningScript&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_PartitioningScript&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> SlidingWindow </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_SlidingWindow&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_SlidingWindow&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> Snapshot </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_Snapshot&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_Snapshot&amp;referringTitle=Home">SS2008</a> </td>
</tr>
</table> <br /> <br />
</div>bonniefeThu, 06 Nov 2008 23:46:52 GMTUpdated Wiki: Home 20081106114652PUpdated Wiki: Homehttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=Home&version=24<div class="wikidoc">
<a href="http://CodePlex.com/SqlServerSamples" class="externalLink">SQL Server Samples Portal Page<span class="externalLinkIcon"></span></a> &gt; SQL Server Scripts Product Samples<br /> <br />This project contains Scripts samples released with Microsoft SQL Server product. Below is the list of these samples. If you are interested in contributing Scripts samples, please let us know by posting in the developers' forum.<br /> <br /><ul>
<li><b>SQL Server 2008</b> samples <a href="/MSFTScrptProdSamples/Release/ProjectReleases.aspx" class="externalLink">download<span class="externalLinkIcon"></span></a>.</li><li><b>SQL Server 2005</b> samples <a href="/MSFTScrptProdSamples/Release/ProjectReleases.aspx?ReleaseId=4046" class="externalLink">download<span class="externalLinkIcon"></span></a>.</li>
</ul>For information about how to use CodePlex to access SQL Server samples, click <a href="http://www.codeplex.com/SqlServerSamples/Wiki/View.aspx?title=HowToUseCodePlex&amp;referringTitle=Home" class="externalLink">here<span class="externalLinkIcon"></span></a>.<br />To download samples databases, click <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx" class="externalLink">here<span class="externalLinkIcon"></span></a> and then click the appropriate MSI file.<br />For release notes and brief descriptions of all the sample databases and code, including restrictions on SQL Express and Vista, click <a href="http://www.codeplex.com/SqlServerSamples/Wiki/View.aspx?title=SQLServerDatabasesandSamplesOverview&amp;referringTitle=Home" class="externalLink">here<span class="externalLinkIcon"></span></a>.<br /> <br /> <br /><table>
<tr>
<th> Sample </th><th> SQL Server 2005 </th><th> SQL Server 2008 </th>
</tr><tr>
<td> Event Notifications Sample </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Event%20Notifications%20Sample&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Event%20Notifications%20Sample&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> AdventureWorksScripts </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_AdventureWorksScripts&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_AdventureWorksScripts&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> Alerts </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_Alerts&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_Alerts&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> FileGroups </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_FileGroups&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_FileGroups&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> PartitioningScript </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_PartitioningScript&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_PartitioningScript&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> SlidingWindow </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_SlidingWindow&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_SlidingWindow&amp;referringTitle=Home">SS2008</a> </td>
</tr><tr>
<td> Snapshot </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005%21Readme_Snapshot&amp;referringTitle=Home">SS2005</a> </td><td> <a href="http://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008%21Readme_Snapshot&amp;referringTitle=Home">SS2008</a> </td>
</tr>
</table> <br /> <br />
</div>ReedMeWed, 27 Aug 2008 23:57:00 GMTUpdated Wiki: Home 20080827115700PUpdated Wiki: SS2008!Readme_Snapshothttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2008!Readme_Snapshot&version=7<div class="wikidoc">
<h2>
Readme_Snapshot Sample
</h2> <br /> 08/06/2008 01:27:32<br /> <br /> <br /> This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. <br />The purpose of the <b>DatabaseSnapshot</b> sample is to demonstrate the database snapshot capabilities of SQL Server. For more information, see &quot;Database Snapshots&quot; in SQL Server Books Online. <br /> <br /><h3>
Scenario
</h3>A database snapshot is a read-only, static view of a database. This database is called the source database. Each database snapshot is transaction-consistent with the source database at the moment of the snapshot's creation. A snapshot persists until it is explicitly dropped by the database owner. Multiple snapshots can exist on a database. This sample creates a new database snapshot of the <b>AdventureWorks</b> sample database.<br /> <br /><h3>
Languages
</h3> Transact-SQL <br /> <br /><h3>
Prerequisites
</h3>Before you run this sample, perform the following tasks:<br /> <br /><ul>
<li> Install SQL Server and make sure you include the following components: </li><li> The Database Engine </li><li> SQL Server Management Studio </li><li> Download the <b>AdventureWorks</b> (OLTP) sample database and SQL Server Database Engine samples available at the Microsoft SQL Server <a href="http://go.microsoft.com/fwlink/?linkid=100108" class="externalLink">Samples and Community Projects Web site<span class="externalLinkIcon"></span></a>. </li>
</ul><h3>
Running the Sample
</h3> <br /><h6>
Installing and Running the Sample
</h6> <br /><ol>
<li>From Management Studio, open the file CreateDatabaseSnapshot.sql script located in the C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Administration\DatabaseSnapshot\Scripts folder, and click <b>Execute</b>. &#169; 2008 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 07 Aug 2008 08:20:19 GMTUpdated Wiki: SS2008!Readme_Snapshot 20080807082019AUpdated Wiki: SS2005!Readme_Snapshothttp://www.codeplex.com/MSFTScrptProdSamples/Wiki/View.aspx?title=SS2005!Readme_Snapshot&version=14<div class="wikidoc">
<h2>
Readme_Snapshot
</h2> <br /> <br /> <br />The purpose of the <b>DatabaseSnapshot</b> sample is to demonstrate the database snapshot capabilities of Microsoft SQL Server 2005. For information about this new feature, refer to the topic, &quot;Database Snapshots&quot; in SQL Server Books Online. <br /> <br /><h3>
Scenario
</h3>A database snapshot is a read-only, static view of a database. This database is called the source database. Each database snapshot is transaction-consistent with the source database at the moment of the snapshot's creation. A snapshot persists until it is explicitly dropped by the database owner. Multiple snapshots can exist on a database. This sample creates a new database snapshot of the <b>AdventureWorks</b> sample database.<br /> <br /><h3>
Languages
</h3>Transact-SQL<br /> <br /><h3>
Prerequisites
</h3>Before running either of the scripts included in this sample, make sure the following software is installed:<br /> <br /><ul>
<li> SQL Server 2005, including the following components: </li><li> Database Engine </li><li> SQL Server Management Studio </li><li><b>AdventureWorks</b> (OLTP) sample database </li><li> SQL Server Engine samples </li>
</ul><h3>
Running the Sample
</h3> <br /><h6>
Installing and Running the Sample
</h6> <br /><ol>
<li>From SQL Server Management Studio, open the file <b>CreateDatabaseSnapshot.sql</b> script located in the C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Administration\DatabaseSnapshot\Scripts folder, and click <b>Execute</b>. &#169; 2007 Microsoft Corporation. All rights reserved.</li>
</ol>
</div>bonniefeThu, 07 Aug 2008 08:20:02 GMTUpdated Wiki: SS2005!Readme_Snapshot 20080807082002A