<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dbsnaps &#187; SQL Server</title>
	<atom:link href="http://www.dbsnaps.com/category/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dbsnaps.com</link>
	<description>database video tutorials</description>
	<lastBuildDate>Sun, 13 Nov 2011 13:50:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server 2008 &#8211; Using Query Hashes and Query Plan Hashes</title>
		<link>http://www.dbsnaps.com/sql-server/sql-server-query-hashes/</link>
		<comments>http://www.dbsnaps.com/sql-server/sql-server-query-hashes/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 11:05:06 +0000</pubDate>
		<dc:creator>Danny Ravid</dc:creator>
				<category><![CDATA[Main-Performance]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server - Latest Articles]]></category>
		<category><![CDATA[DMV]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Query Hashes]]></category>
		<category><![CDATA[Query Plan Hashes]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[sys.dm_exec_query_plan]]></category>
		<category><![CDATA[sys.dm_exec_query_stats]]></category>
		<category><![CDATA[sys.dm_exec_requests]]></category>

		<guid isPermaLink="false">http://www.dbsnaps.com/?p=643</guid>
		<description><![CDATA[In this post we will discuss SQL tuning methods by using DMV (sys.dm_exec_query_stats and sys.dm_exec_requests) and how to use Query Hashes and Query Plan Hashes in SQL Server 2008.]]></description>
			<content:encoded><![CDATA[<p><strong> </strong></p>
<p>When searching for resource-intensive queries, we can use the sys.dm_exec_query_stats and sys.dm_exec_requests.</p>
<p>These dynamic management views already where introduced in SQL server 2005.<br />
In SQL Server 2008 there are a couple of columns added to the sys.dm_exec_query_stats and sys.dm_exec_requests - <strong>The query_hash and the query_plan_hash </strong>column.</p>
<p>By using these columns we can find and tune similar queries that collectively consume significant system resources, and help determine the aggregate resource usage for similar queries and similar query execution plans.</p>
<p>First let&#8217;s look at the following queries:</p>
<pre class="brush: sql;">
use AdventureWorks
go
SELECT SOD.ProductID ,
sum((UnitPrice * OrderQty ) - (UnitPriceDiscount * OrderQty ) ) TotalSaleAmount
FROM Sales.SalesOrderHeader SOH
JOIN Sales.SalesOrderDetail SOD
   ON SOH.SalesOrderID = SOD.SalesOrderID
JOIN Production.Product P
   ON P.ProductID = SOD.ProductID
WHERE SOH.CustomerID = 520
AND SOD.OrderQty &gt; 10
GROUP BY SOD.ProductID;
go

SELECT SOD.ProductID ,sum((UnitPrice * OrderQty ) - (UnitPriceDiscount * OrderQty ) ) TotalSaleAmount
FROM Sales.SalesOrderHeader SOH
JOIN Sales.SalesOrderDetail SOD
   ON SOH.SalesOrderID = SOD.SalesOrderID
JOIN Production.Product P
   ON P.ProductID = SOD.ProductID
WHERE SOH.CustomerID = 523
AND SOD.OrderQty &gt; 10
GROUP BY SOD.ProductID;
go
</pre>
<p><strong> </strong></p>
<p>These queries are only different in the constant value supplied for the CustomerID column; Now let&#8217;s look at the Query_Hash values of this both queries:</p>
<pre class="brush: sql;">
SELECT st.text AS &quot;Query Text&quot;, qs.query_hash AS &quot;Query Hash&quot;
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text (qs.sql_handle) st
WHERE st.text ='SELECT SOD.ProductID ,sum((UnitPrice * OrderQty ) - (UnitPriceDiscount * OrderQty ) ) TotalSaleAmount FROM Sales.SalesOrderHeader SOH JOIN Sales.SalesOrderDetail SOD    ON SOH.SalesOrderID = SOD.SalesOrderID JOIN Production.Product P    ON P.ProductID = SOD.ProductID WHERE SOH.CustomerID = 520 AND SOD.OrderQty &gt; 10 GROUP BY SOD.ProductID;'
OR st.text = ' SELECT SOD.ProductID ,sum((UnitPrice * OrderQty ) - (UnitPriceDiscount * OrderQty ) ) TotalSaleAmount FROM Sales.SalesOrderHeader SOH JOIN Sales.SalesOrderDetail SOD    ON SOH.SalesOrderID = SOD.SalesOrderID JOIN Production.Product P    ON P.ProductID = SOD.ProductID WHERE SOH.CustomerID = 523 AND SOD.OrderQty &gt; 10 GROUP BY SOD.ProductID;'
</pre>
<p>We can see that although these queries&#8217; text does not exactly match, sql server 2008 identifies these queries as having the same structure and therefore have the same hash values.  This gives a significant advantage to help us identifying similar queries.  We can for instance use this information to find which queries would benefit from using parameterization to improve performance.  For example, let&#8217;s change the logic of the queries:</p>
<pre class="brush: sql;">
use AdventureWorks
go
SELECT SOD.ProductID , sum((UnitPrice * OrderQty ) - (UnitPriceDiscount * OrderQty ) ) TotalSaleAmount
FROM Sales.SalesOrderHeader SOH
JOIN Sales.SalesOrderDetail SOD
   ON SOH.SalesOrderID = SOD.SalesOrderID
JOIN Production.Product P
   on P.ProductID = SOD.ProductID
WHERE SOH.CustomerID = 520
AND SOD.OrderQty &gt; 10
GROUP BY SOD.ProductID;
go
SELECT  SOD.ProductID , sum((UnitPrice * OrderQty ) - (UnitPriceDiscount * OrderQty ) ) TotalSaleAmount
from Sales.SalesOrderHeader SOH
join Sales.SalesOrderDetail SOD
   on SOH.SalesOrderID = SOD.SalesOrderID
Join Production.Product P
   on P.ProductID = SOD.ProductID
where SOH.CustomerID = 523
OR SOD.OrderQty &gt; 10
GROUP BY SOD.ProductID;

go
</pre>
<p>Now, let&#8217;s find out the query hash for these two queries:</p>
<pre class="brush: sql;">
SELECT st.text AS &quot;Query Text&quot;, qs.query_hash AS &quot;Query Hash&quot;
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text (qs.sql_handle) st
WHERE st.text ='SELECT SOD.ProductID , sum((UnitPrice * OrderQty ) - (UnitPriceDiscount * OrderQty ) ) TotalSaleAmount FROM Sales.SalesOrderHeader SOH JOIN Sales.SalesOrderDetail SOD    ON SOH.SalesOrderID = SOD.SalesOrderID JOIN Production.Product P    ON P.ProductID = SOD.ProductID WHERE SOH.CustomerID = 520 AND SOD.OrderQty &gt; 10 GROUP BY SOD.ProductID;'
OR st.text = 'SELECT SOD.ProductID , sum((UnitPrice * OrderQty ) - (UnitPriceDiscount * OrderQty ) ) TotalSaleAmount from Sales.SalesOrderHeader SOH join Sales.SalesOrderDetail SOD    ON SOH.SalesOrderID = SOD.SalesOrderID JOIN Production.Product P    ON P.ProductID = SOD.ProductID WHERE SOH.CustomerID = 523 OR SOD.OrderQty &gt; 10 GROUP BY SOD.ProductID;' </pre>
<p><strong> </strong>We see that these 2 queries has different query hashes, so they to do not share the same logic.  Now let us examine the query plan hash column, how can we use this column to find performance issues?  Consider that you have similar queries like we have seen, but somehow they do not have the same query plan, this sometimes indicates a performance problem;  Let&#8217;s examine the following example (from SQL 2008 BOL):</p>
<pre class="brush: sql;">
USE AdventureWorks;
GO
SET STATISTICS XML ON;

SELECT T.TransactionID, T.TransactionDate, P.ProductID, P.Name
FROM Production.TransactionHistory T
JOIN Production.Product P
   ON T.ProductID = P.ProductID
WHERE P.ProductID = 1;
GO

SELECT T.TransactionID, T.TransactionDate, P.ProductID, P.Name
FROM Production.TransactionHistory T
JOIN Production.Product P
   ON T.ProductID = P.ProductID
WHERE P.ProductID = 3;
GO

SET STATISTICS XML OFF;
GO </pre>
<p><strong> </strong>If you examine the query&#8217;s plan you will see that they are different, although the query hashes are the same because we just changed the value for the ProductID column.</p>
<pre class="brush: sql;">
SELECT ST.text AS &quot;Query Text&quot;,QS.query_plan_hash ,QP.query_plan
FROM sys.dm_exec_query_stats QS
CROSS APPLY sys.dm_exec_sql_text (QS.sql_handle) ST
CROSS APPLY sys.dm_exec_query_plan(QS.plan_handle) QP
WHERE ST.text = 'SELECT T.TransactionID, T.TransactionDate, P.ProductID, P.Name FROM Production.TransactionHistory T JOIN Production.Product P ON T.ProductID = P.ProductID WHERE P.ProductID = 1;'
OR ST.text = 'SELECT T.TransactionID, T.TransactionDate, P.ProductID, P.Name FROM Production.TransactionHistory T JOIN Production.Product P    ON T.ProductID = P.ProductID WHERE P.ProductID = 3;'; </pre>
<p><strong> </strong>Below you can find a query to find similar queries with differnat query plans, in order to find the cost of each distinct query plan,we will use Xquery on the Query Plan Xml Column :</p>
<pre class="brush: sql;">
SELECT max([QueryText]) QueryText , max(SimilarQueries.query_plan.value('(//@StatementSubTreeCost)[1]','float')) QueryCost
FROM (SELECT QS1.*,ST.text AS QueryText,QP1.query_plan
      FROM sys.dm_exec_query_stats QS1
      CROSS APPLY sys.dm_exec_sql_text (QS1.sql_handle) ST
      CROSS APPLY sys.dm_exec_query_plan(QS1.plan_handle) QP1
      JOIN sys.dm_exec_query_stats QS2
         ON QS1.query_hash = QS2.query_hash
      WHERE QS1.query_plan_hash &lt;&gt; QS2.query_plan_hash ) as SimilarQueries
GROUP BY SimilarQueries.query_plan_hash
ORDER BY 1 </pre>
<p>We can determine that the second query plan is more costly. it will be much nicer if we can get in the same result set the Xml Query Plan itself; this requires some TSQL juggling around, since the XML data type cannot be used in a group by or with an aggregation function.</p>
<pre class="brush: sql;">
SELECT QueryText ,QueryCost,QP.query_plan QueryPlan
FROM (select max(QueryText) QueryText ,max(SimilarQueries.query_plan.value('(//@StatementSubTreeCost)[1]','float')) QueryCost ,max(plan_handle) plan_handle
      FROM  (SELECT QS1.*,ST.text AS QueryText,QP1.query_plan
             FROM sys.dm_exec_query_stats QS1
             CROSS APPLY sys.dm_exec_sql_text (QS1.sql_handle) ST
             CROSS APPLY sys.dm_exec_query_plan(QS1.plan_handle) QP1
             JOIN sys.dm_exec_query_stats QS2
                on QS1.query_hash = QS2.query_hash
             WHERE where QS1.query_plan_hash &lt;&gt; QS2.query_plan_hash ) as SimilarQueries
     GROUP BY SimilarQueries.query_plan_hash) SimilarQueriesCost
CROSS APPLY sys.dm_exec_query_plan(plan_handle) QP
ORDER BY 1
</pre>
<p><strong> </strong>In SQL 2008 Management Studio when we will click the Query Plan Xml Column you will immediately get the graphical representation of the query plan, this enables us to examine immediately the execution plan of the costly query plans.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/sql-server/sql-server-query-hashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rolling back TRUNCATE statements in SQL Server</title>
		<link>http://www.dbsnaps.com/sql-server/tips-tricks-sql-server/rolling-back-truncate-statements-in-sql-server/</link>
		<comments>http://www.dbsnaps.com/sql-server/tips-tricks-sql-server/rolling-back-truncate-statements-in-sql-server/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 09:49:58 +0000</pubDate>
		<dc:creator>Roni Vered</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Main-Administration]]></category>
		<category><![CDATA[SQL Server - Latest Articles]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[BEGIN TRAN]]></category>
		<category><![CDATA[DELETE]]></category>
		<category><![CDATA[Rollback]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[TRUNCATE]]></category>

		<guid isPermaLink="false">http://www.dbsnaps.com/?p=374</guid>
		<description><![CDATA[There are two main ways to delete all records from a table - DELETE and TRUNCATE commands, but if we do, can we rollback the operation?]]></description>
			<content:encoded><![CDATA[<p>There are two main statements used for deleting data from a table in SQL SERVER:</p>
<ul>
<li>TRUNCATE</li>
<li>DELETE</li>
</ul>
<p>The two commands achieve the same result; however, each of the commands acts a little bit different. Each of the two commands have advantages, limitations, and consequences, which have to be considered when deciding which method to use.</p>
<p>In this post we will concentrate in <em>one</em> aspect of these commands usage – <em>the ability to rollback each operation</em>.</p>
<p>DELETE statements delete rows one at a time, logging each row in the transaction log and maintaining the log sequence number (LSN) information.<br />
Even though it will consumes more database resources, it comes in handy as these transactions can be <strong>rolled back</strong> if necessary by using the log files, when the recovery model of the database is set to full.</p>
<p>But what happens when you issue the <em>TRUNCATE </em>command?</p>
<p>The TRUNCATE statement is much faster statement than the DELETE command.<br />
It deletes all records in a table by deallocating the data pages used to store the table&#8217;s data. This operation has a limited logging in the transaction log (only the page deallocations are recorded in the transaction log). In addition fewer locks are acquired with this statement in compare to the DELETE statement.<br />
As a result of the above it is commonly believed that records removed by the TRUNCATE statement cannot be restored – rolled back.</p>
<p>It is true in most cases, however <strong>DELETE and TRUNCATE can both be rolled back</strong> when they are executed inside a ‘BEGIN <em>TRANSACTION’</em> block and the current session has not yet ended.<br />
In other words, when the TRUNCATE statement has not been committed yet, it can be rolled back</p>
<p>The following code demonstrates a scenario when a TRUNCATE can be rolled back for that particular session.</p>
<pre class="brush: sql;">
--Creating a testTable for the demonstration
CREATE TABLE TESTTABLE (ID INT)

--Inserting rows into the testTable.
INSERT INTO TESTTABLE
SELECT TOP 1000 OBJECT_ID FROM SYS.OBJECTS
BEGIN TRAN
   --Truncating the table
   TRUNCATE TABLE TESTTABLE
   --No rows will return
   SELECT * FROM TESTTABLE
ROLLBACK

--The original rows from testTable will return
SELECT * FROM TESTTABLE

--Dropping the testTable.
DROP TABLE TESTTABLE
</pre>
<p><strong>To summarize,<br />
</strong>DELETE can always be rolled back-</p>
<ul>
<li><span style="font-size: 13.3333px">When the recovery model of the database is set to SIMPLE, the statement can be rolled back &#8211; when the statement is executed inside a ‘BEGIN TRANSACTION’ block.</span></li>
<li><span style="font-size: 13.3333px">When the recovery model of the database is set to FULL, the statement can also be recovered from the log files.</span></li>
</ul>
<p><span style="font-size: 13.3333px">TRUNCATE can or cannot be rolled back, depends if it is executed from within a ‘BEGIN TRANSACTION’ block.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/sql-server/tips-tricks-sql-server/rolling-back-truncate-statements-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server &#8211; How to determine instance uptime</title>
		<link>http://www.dbsnaps.com/sql-server/334/</link>
		<comments>http://www.dbsnaps.com/sql-server/334/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 09:29:40 +0000</pubDate>
		<dc:creator>Alon Spiegel</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server - Latest Articles]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[crdate]]></category>
		<category><![CDATA[Instance Uptime]]></category>
		<category><![CDATA[sysdatabase]]></category>
		<category><![CDATA[tempdb]]></category>

		<guid isPermaLink="false">http://www.dbsnaps.com/?p=334</guid>
		<description><![CDATA[In this article we will demonstrate how to retrieve the startup time of SQL Server]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, SQL Server does not provide an easy and simple query that answers this question. What we could do is use the fact that tempdb database is being created every time we start SQL Server and query the create time of this reincarnating temporary database. The table/columns we are interested is sysdatabase.crdate  The following statement demonstrates it. Just copy it and run it in SSMS.</p>
<p>(I have written it for SQL 2005 but I guess it runs both on 2000 and 2008 versions)</p>
<pre class="brush: sql;">

declare @startupDate datetime
,		@days bigint
,		@hours bigint
,		@minutes bigint
,		@seconds bigint

select	@startupDate = CrDate
,		@seconds = DateDiff(second, CrDate, getdate())
,		@days = @seconds/60/60/24
,		@seconds = @seconds - (@days*60*60*24)
,		@hours = @seconds/60/60
,		@seconds = @seconds - (@hours*60*60)
,		@minutes = @seconds/60
,		@seconds = @seconds - (@minutes*60)

from	sysdatabases (nolock)
where	[name] = 'TempDb'

select	@startupDate startup_time
,		cast(@days as varchar) + ' days ' +
		case when @hours &lt; 10 then '0' else '' end + cast(@hours as varchar) + ':' +
		case when @minutes &lt; 10 then '0' else '' end + cast(@minutes as varchar) + ':' +
		case when @seconds &lt; 10 then '0' else '' end + cast(@seconds as varchar)
		as online_duration
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/sql-server/334/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server &#8211; Determining Index Usage</title>
		<link>http://www.dbsnaps.com/sql-server/sql-server-determining-index-usage/</link>
		<comments>http://www.dbsnaps.com/sql-server/sql-server-determining-index-usage/#comments</comments>
		<pubDate>Tue, 04 May 2010 08:17:47 +0000</pubDate>
		<dc:creator>Roni Vered</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server - Latest Articles]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[DMV]]></category>
		<category><![CDATA[dm_db_index_usage_stats]]></category>
		<category><![CDATA[Index Usage]]></category>

		<guid isPermaLink="false">http://www.dbsnaps.com/?p=211</guid>
		<description><![CDATA[Indexes have large effect on each database. They can improve queries performance dramatically, but too many of them can cause performance degradation and overhead when changing data. This tip contains a script that will help you to find useful information about index usage in your database.]]></description>
			<content:encoded><![CDATA[<p>Indexes have large effect on each database. They can improve queries performance dramatically, but too many of them can cause performance degradation and overhead when changing data. This tip contains a script that will help you to find useful information about index usage in your database. It is compatible to SQL Server 2005 and up.</p>
<p>You can use this query to determine which indexes are used only lightly by your applications. You can also use the query to determine which indexes are incurring maintenance overhead. You may want to consider dropping indexes that incur maintenance overhead, but are not used for queries, or are only infrequently used for queries.</p>
<p>The query is based on the DMV sys.dm_db_index_usage_stats. The counters in the view are initialized to empty whenever the SQL Server (MSSQLSERVER) service is started.</p>
<p>Every individual seek, scan, lookup, or update on the specified index by one query or DML execution is counted as a use of that index and increments the corresponding counter in this view.<br />
The index information is gathered both for user operations (e.g. submitted queries), and for internal operations (e.g. scans for gathering statistics).</p>
<pre class="brush: sql;">
SELECT
sys.objects.name AS object_name,
sys.indexes.name AS index_name,
case
when (is_unique = 1 and is_primary_key = 1) then 'PK UNIQUE '
when is_unique = 1  then 'UNIQUE '
else ''
end + sys.indexes.type_desc type_desc,
c.index_columns AS index_columns_key,
sys.dm_db_index_usage_stats.user_seeks,
sys.dm_db_index_usage_stats.user_scans,
sys.dm_db_index_usage_stats.user_lookups,
sys.dm_db_index_usage_stats.user_updates,
sys.dm_db_index_usage_stats.last_user_seek,
sys.dm_db_index_usage_stats.last_user_scan,
sys.dm_db_index_usage_stats.last_user_lookup,
sys.dm_db_index_usage_stats.last_user_update
FROM sys.objects
JOIN sys.indexes
ON sys.indexes.object_id=sys.objects.object_id
JOIN
(SELECT distinct
object_id,
index_id,
stuff((SELECT ','+col_name(object_id,column_id ) as 'data()'
FROM sys.index_columns t2
WHERE t1.object_id =t2.object_id
and t1.index_id = t2.index_id
FOR XML PATH ('')),1,1,'') as 'index_columns'
FROM sys.index_columns t1
) c
ON c.index_id = sys.indexes.index_id
AND c.object_id = sys.indexes.object_id
LEFT OUTER JOIN sys.dm_db_index_usage_stats
ON sys.indexes.index_id=sys.dm_db_index_usage_stats.index_id
AND sys.indexes.object_id=sys.dm_db_index_usage_stats.object_id
AND (
(sys.dm_db_index_usage_stats.user_seeks is null)
OR  (
( sys.dm_db_index_usage_stats.user_seeks &lt; 100 )
AND ( sys.dm_db_index_usage_stats.user_scans &lt; 100 )
AND ( sys.dm_db_index_usage_stats.user_lookups &lt; 100 )
)
)
WHERE sys.objects.type='u'                 --Only UserTables will be selected
AND sys.indexes.type_desc  &lt;&gt; 'HEAP'       --Only indexes will appear, not HEAP tables
--AND sys.objects.name = ''                --In case you would like to monitor only a specific table, put the table name
ORDER BY 1
</pre>
<p><span style="text-decoration: underline;">Information about the main columns in this DMV:</span></p>
<p><strong>User Seeks</strong>: the number of times the index has been used by a user query in a seek operation (one specific row)</p>
<p><strong>User Scans</strong>: the number of times the index has been used by scanning the leaf pages of the index for data</p>
<p><strong>User Lookup</strong>: for clustered indexes only, this is the number of times the index has been used in a &#8220;bookmark lookup&#8221; to fetch the full row. This is because non-clustered indexes use the clustered indexes key as the pointer to the base row</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/sql-server/sql-server-determining-index-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server &#8211; Values of Newly Added Columns</title>
		<link>http://www.dbsnaps.com/sql-server/sql-server-values-of-newly-added-columns/</link>
		<comments>http://www.dbsnaps.com/sql-server/sql-server-values-of-newly-added-columns/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 10:56:47 +0000</pubDate>
		<dc:creator>Liron Amitzi</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Add Column]]></category>
		<category><![CDATA[Default Value]]></category>
		<category><![CDATA[NULL]]></category>
		<category><![CDATA[Nullable Column]]></category>

		<guid isPermaLink="false">http://dbsnaps.oracletutorialvideos.com/?p=132</guid>
		<description><![CDATA[What happens if we add a column to a table? What value does this column get?]]></description>
			<content:encoded><![CDATA[<p>When we add a column to a table, what happens to existing rows?<br />
Will the new column be null? Or will have a value?</p>
<p>This depends on how we add the column.<br />
We have four different options to add a new column to an existing table:</p>
<ul>
<li>Adding a nullable column with no default value &#8211; in this case the column will be added to the table, and will be null in all existing rows.</li>
<li>Adding a &#8220;no null&#8221; column without default value &#8211; this option will return an error. Existing rows will have null value in the new column and this is not legal. In order to add this type of column is to add a nullable column, update all the rows to have values for this column, and then change it to &#8220;not null&#8221;.</li>
<li>Adding a &#8220;nullable&#8221; column with default value &#8211; in this case, existing rows will have null for this column, but new rows will get the default value.</li>
<li>Adding a &#8220;no null&#8221; column with default value-after adding this type of column, existing rows will get the default value for this column and it will be not null.</li>
</ul>
<p>Adding a column as described in one of the first 3 options will complete quickly, as only the definition of the table changes.<br />
We have to be careful when using the last option will. Adding a column as described in the last option will implicitly cause an update of all the existing rows in the table and may take a long time to complete.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/sql-server/sql-server-values-of-newly-added-columns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 Log Shipping tutorial</title>
		<link>http://www.dbsnaps.com/videos/sql-server-2005-log-shipping/</link>
		<comments>http://www.dbsnaps.com/videos/sql-server-2005-log-shipping/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 19:18:51 +0000</pubDate>
		<dc:creator>Oded Raz</dc:creator>
				<category><![CDATA[High Availability]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server - Latest Articles]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Log Shipping Video]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://dbsnaps.oracletutorialvideos.com/?p=105</guid>
		<description><![CDATA[Log shipping is the process of automating transaction log copy and apply in order to maintain identical database copy for high-availability or disaster recovery proposes. ]]></description>
			<content:encoded><![CDATA[<p>Log shipping is the process of automating transaction log copy and apply in order to maintain identical database copy for high-availability or disaster recovery proposes.</p>
<p>Transaction log files are copied from the production SQL server, and then restoring them onto a standby server. But this is not all. The key feature of log shipping is that is will automatically backup transaction logs throughout the day (for whatever interval you specify) and automatically restore them on the standby server. This in effect keeps the two SQL Servers in &#8220;synch&#8221;. Should the production server fail, all you have to do is point the users to the new server, and you are all set. Well, its not really that easy, but it comes close if you put enough effort into your log shipping setup.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/videos/sql-server-2005-log-shipping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server Login Audit tutorial</title>
		<link>http://www.dbsnaps.com/videos/sql-server-login-audit/</link>
		<comments>http://www.dbsnaps.com/videos/sql-server-login-audit/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 19:07:45 +0000</pubDate>
		<dc:creator>Oded Raz</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server - Latest Articles]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Audit Login]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://dbsnaps.oracletutorialvideos.com/?p=101</guid>
		<description><![CDATA[Learn how to audit sql server's login, its simple and its quick.]]></description>
			<content:encoded><![CDATA[<p>Learn how to audit sql server&#8217;s login, its simple and its quick.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/videos/sql-server-login-audit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 Backup &amp; Restore tutorial</title>
		<link>http://www.dbsnaps.com/videos/sql-server-2005-backup-restore/</link>
		<comments>http://www.dbsnaps.com/videos/sql-server-2005-backup-restore/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 19:04:16 +0000</pubDate>
		<dc:creator>Oded Raz</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Backup & Restore]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://dbsnaps.oracletutorialvideos.com/?p=96</guid>
		<description><![CDATA[Microsoft SQL Server enables you to back up and restore your databases. The SQL Server backup and restore component provides an important safeguard for protecting critical data stored in SQL Server databases.]]></description>
			<content:encoded><![CDATA[<p>Microsoft SQL Server enables you to back up and restore your databases.  The SQL Server backup and restore component provides an important  safeguard for protecting critical data stored in SQL Server databases. A  well-planned backup and restore strategy helps protect databases  against data loss caused by a variety of failures. Test your strategy by  restoring a set of backups and then recovering your database to prepare  you to respond effectively to a disaster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/videos/sql-server-2005-backup-restore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 Mirroring tutorial</title>
		<link>http://www.dbsnaps.com/videos/sql-server-2005-mirroring-tutorial/</link>
		<comments>http://www.dbsnaps.com/videos/sql-server-2005-mirroring-tutorial/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 18:51:43 +0000</pubDate>
		<dc:creator>Oded Raz</dc:creator>
				<category><![CDATA[High Availability]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server - Latest Articles]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Mirroring]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://dbsnaps.oracletutorialvideos.com/?p=90</guid>
		<description><![CDATA[SQL Server 2005 provides a set of high availability methods that the users can use to achieve fault tolerance and to prevent server outages and data loss. The selection of the high availability method depends on various factors. Some DBAs need the servers to be available 24/7, while others can afford an outage of a couple of hours. Cost also plays a role in the selection. For example, Clustering is an expensive high availability method when compared to Database Mirroring, but it allows the user to failover immediately.]]></description>
			<content:encoded><![CDATA[<p>SQL Server 2005 provides a set of high availability methods that the  users can use to achieve fault tolerance and to prevent server outages  and data loss. The selection of the high availability method depends on  various factors. Some DBAs need the servers to be available 24/7, while  others can afford an outage of a couple of hours. Cost also plays a role  in the selection. For example, Clustering is an expensive high  availability method when compared to Database Mirroring, but it allows  the user to failover immediately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dbsnaps.com/videos/sql-server-2005-mirroring-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

