<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlserver-indo.org/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">kasim.wirama</title><subtitle type="html" /><id>http://sqlserver-indo.org/blogs/kasimwirama/atom.aspx</id><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/default.aspx" /><link rel="self" type="application/atom+xml" href="http://sqlserver-indo.org/blogs/kasimwirama/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20416.853">Community Server</generator><updated>2009-01-29T21:18:00Z</updated><entry><title>How to Migrate Non XML Column into XML Column</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/26/how-to-migrate-non-xml-column-into-xml-column.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/26/how-to-migrate-non-xml-column-into-xml-column.aspx</id><published>2009-07-25T13:27:00Z</published><updated>2009-07-25T13:27:00Z</updated><content type="html">&lt;h2 style="TEXT-ALIGN:center;MARGIN:10pt 0in 0pt;" align="center"&gt;&lt;font color="#4f81bd" size="4" face="Cambria"&gt;How to Migrate Non XML Column into XML Column&lt;/font&gt;&lt;/h2&gt;
&lt;h3 style="TEXT-ALIGN:center;MARGIN:10pt 0in 0pt;" align="center"&gt;&lt;font color="#4f81bd" size="3" face="Cambria"&gt;By : Kasim Wirama, MCITP, MCDBA&lt;/font&gt;&lt;/h3&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="TEXT-ALIGN:justify;MARGIN:0in 0in 10pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;You might store xml data in text or varchar column type in SQL Server 2000 or previous version because it doesn’t support XML data type for storage. Now SQL Server 2005 and SQL Server 2008 support XML data type natively. It means that developer could declare XML variable, XML column, XML input/output parameters in stored procedure and user defined function and return value from user defined function; so converting xml data in text or varchar column type into xml column type is recommended because you can put high performance XML validation and very easy to query XML data with available XQuery methods.&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 10pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;Here is safe procedure to do conversion into XML column:&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpFirst"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;1.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Add temporary column with varchar(max) or nvarchar(max) or text type&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;2.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Set value from a source varchar column into step 1&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;3.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Drop source varchar column&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;4.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Create new column whose name is same as dropped column on step 3.&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;5.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Update back column in step 4 from value of column in step 2.&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 10pt 0.5in;mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpLast"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;6.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Drop the temporary column.&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 10pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;Here is sample how to do this.&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt 0.5in;" class="MsoListParagraphCxSpFirst"&gt;&lt;font size="3" face="Calibri"&gt;CREATE TABLE dbo.CustomerSalesRecord&lt;br /&gt;(&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;CustomerId int primary key,&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;SalesRecord nvarchar(8000)&lt;br /&gt;);&lt;br /&gt;GO&lt;br /&gt;INSERT INTO dbo.CustomerSalesRecord&lt;br /&gt;SELECT c.customerId,&lt;br /&gt;(&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt 0.5in;" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="3" face="Calibri"&gt;SELECT&lt;br /&gt;FROM sales.salesorderheader as h&lt;br /&gt;WHERE h.CustomerId = c.CustomerId&lt;br /&gt;FOR&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;XML AUTO, ROOT(‘Orders’)&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt 0.5in;" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="3" face="Calibri"&gt;) as SalesRecord&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt 0.5in;" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="3" face="Calibri"&gt;FROM Sales.Customer as c;&lt;br style="mso-special-character:line-break;" /&gt;&lt;br style="mso-special-character:line-break;" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l0 level1 lfo2;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;1.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;First step&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt 0.5in;" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="3" face="Calibri"&gt;ALTER TABLE dbo.CustomerSalesRecord&lt;br /&gt;ADD SalesRecord_temp NVARCHAR(MAX);&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l0 level1 lfo2;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;2.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Second step&lt;br /&gt;UPDATE dbo.CustomerSalesRecord&lt;br /&gt;SET SalesRecord_temp = SalesRecord;&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l0 level1 lfo2;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;3.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Third step&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt 0.5in;" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="3" face="Calibri"&gt;ALTER TABLE dbo.CustomerSalesRecord&lt;br /&gt;DROP COLUMN SalesRecord;&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l0 level1 lfo2;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;4.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Fourth step&lt;br /&gt;ALTER TABLE dbo.CustomerSalesRecord&lt;br /&gt;ADD SalesRecord XML;&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l0 level1 lfo2;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;5.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Fifth step&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt 0.5in;" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="3" face="Calibri"&gt;UPDATE dbo.CustomerSalesRecord&lt;br /&gt;SET SalesRecord = CONVERT(XML, SalesRecord_temp);&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="TEXT-INDENT:-0.25in;MARGIN:0in 0in 0pt 0.5in;mso-list:l0 level1 lfo2;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font size="3" face="Calibri"&gt;6.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;Sixth step&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 0pt 0.5in;" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="3" face="Calibri"&gt;ALTER TABLE dbo.CustomerSalesRecord&lt;br /&gt;DROP COLUMN SalesRecord_temp;&lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=455" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Detect Database Blocking Issue with SQL Server Dynamic Management View</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/23/detect-database-blocking-issue-with-sql-server-dynamic-management-view.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/23/detect-database-blocking-issue-with-sql-server-dynamic-management-view.aspx</id><published>2009-07-22T04:00:00Z</published><updated>2009-07-22T04:00:00Z</updated><content type="html">&lt;font face="Cambria" color="#4f81bd" size="4"&gt;
&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;Detect Database Blocking Issue with SQL Server Dynamic Management View&lt;/font&gt;&lt;/h2&gt;
&lt;h3 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="3"&gt;By : Kasim Wirama, MCITP, MCDBA&lt;/font&gt;&lt;/h3&gt;&lt;/font&gt;
&lt;p&gt;&lt;font face="Calibri" size="3"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;DBA has responsibility to maintain database from backup-restore, data integrity until smooth database daily operation. Most common problem regarding to database operation especially busy database activity is blocking and deadlocking. For this posting, I show you how to detect blocking on your SQL Server by using DMV (Dynamic Management View).&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;DMV has been introduced since SQL Server 2005. DMV for detecting blocking is sys.dm_tran_locks. Many advantage you use the DMV over sp_lock, sp_who2, sp_who and the like. Its advantages are that the DMV could show you resource location and you could export resultset for further analysis.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Back to sys.dm_tran_locks, you can detect blocking by joining to the DMV itself as query shown below&lt;br /&gt;SELECT&lt;br /&gt;l.*&lt;br /&gt;FROM sys.dm_tran_locks as l&lt;br /&gt;JOIN sys.dm_tran_locks as l1&lt;br /&gt;ON l.resource_associated_entity_id = l1.resource_associated_entity_id&lt;br /&gt;WHERE l.request_status &amp;lt;&amp;gt; l1.request_status&lt;br /&gt;AND&lt;br /&gt;( l.resource_description = l1.resource_description OR (l.resource_description IS NULL AND l1.resource_description IS NULL))&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;To see blocking scenario you can create sample table below :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;USE tempdb&lt;br /&gt;GO&lt;br /&gt;CREATE TABLE test (cola varchar(10));&lt;br /&gt;GO&lt;br /&gt;INSERT INTO test VALUES (‘a’);&lt;br style="mso-special-character:line-break;" /&gt;&lt;br style="mso-special-character:line-break;" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Open first connection (in SSMS open new window designer), and issue then execute query below :&lt;br /&gt;USE tempdb&lt;br /&gt;GO&lt;br /&gt;BEGIN TRAN&lt;br /&gt;UPDATE test SET cola = ‘b’;&lt;br /&gt;WAITFOR DELAY ’00:10:00’;&lt;br /&gt;ROLLBACK TRAN&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Open second connection, issue the below :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;USE tempdb&lt;br /&gt;GO&lt;br /&gt;SELECT * FROM test;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Execute the DMV then it display 2 records, to display object name getting involved in blocking, you can issue query below :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;SELECT&lt;br /&gt;db_name(l.resource_database_id) as [database name],&lt;br /&gt;CASE l.resource_type&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;WHEN ‘object’ then object_name(l.resource_associated_entity_id)&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;WHEN ‘database’ then ‘databae’&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;ELSE&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CASE WHEN l.resource_database_id = db_id() THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(SELECT object_Name(object_id) FROM sys.partitions WHERE hobt_id = l.resource_associated_entity_id)&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ELSE NULL&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;END&lt;br /&gt;END,&lt;br /&gt;l.*&lt;br /&gt;FROM sys.dm_tran_locks as l&lt;br /&gt;JOIN sys.dm_tran_locks as l1&lt;br /&gt;ON l.resource_associated_entity_id = l1.resource_associated_entity_id&lt;br /&gt;WHERE l.request_status &amp;lt;&amp;gt; l1.request_status&lt;br /&gt;AND&lt;br /&gt;( l.resource_description = l1.resource_description OR (l.resource_description IS NULL AND l1.resource_description IS NULL));&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;If you need to know what queries getting involved with blocking you can get query information from sys.dm_exec_requests and DMV function : sys.dm_exec_sql_text. Here is the DMV query :&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:11pt;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;SELECT&lt;br /&gt;db_name(l.resource_database_id) as [database name],&lt;br /&gt;CASE l.resource_type&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;WHEN ‘object’ then object_name(l.resource_associated_entity_id)&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;WHEN ‘database’ then ‘databae’&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;ELSE&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CASE WHEN l.resource_database_id = db_id() THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(SELECT object_Name(object_id) FROM sys.partitions WHERE hobt_id = l.resource_associated_entity_id)&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ELSE NULL&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;END&lt;br /&gt;END,&lt;br /&gt;( SELECT t.[text] &lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;FROM sys.dm_exec_requests r&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;CROSS APPLY sys.dm_exec_sql_text (r.sql_handle) AS t&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;WHERE r.session_id = l.request_session_id&lt;br /&gt;),&lt;br /&gt;l.*&lt;br /&gt;FROM sys.dm_tran_locks as l&lt;br /&gt;JOIN sys.dm_tran_locks as l1&lt;br /&gt;ON l.resource_associated_entity_id = l1.resource_associated_entity_id&lt;br /&gt;WHERE l.request_status &amp;lt;&amp;gt; l1.request_status&lt;br /&gt;AND&lt;br /&gt;( l.resource_description = l1.resource_description OR (l.resource_description IS NULL AND l1.resource_description IS NULL)).&lt;/span&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=453" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>MERGE Statement in SQL Server 2008</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/22/merge-statement-in-sql-server-2008.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/22/merge-statement-in-sql-server-2008.aspx</id><published>2009-07-21T22:37:00Z</published><updated>2009-07-21T22:37:00Z</updated><content type="html">&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;MERGE Statement in SQL Server 2008&lt;/font&gt;&lt;/h2&gt;
&lt;h3 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="3"&gt;By : Kasim Wirama, MCITP, MCDBA&lt;/font&gt;&lt;/h3&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;In TSQL area, SQL Server 2008 has some enhancements; one of them is ability to wrap several DML statement into one by MERGE statement. Syntax for MERGE statement is :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;MERGE &amp;lt;target table&amp;gt; [AS &amp;lt;target table alias&amp;gt;]&lt;br /&gt;USING &amp;lt;source table/query/view&amp;gt; [AS &amp;lt;source alias name&amp;gt;]&lt;br /&gt;ON &amp;lt;join condition&amp;gt;&lt;br /&gt;WHEN MATCHED THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;UPDATE or DELETE statement&amp;gt;&lt;br /&gt;WHEN NOT MATCHED BY TARGET THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;INSERT statement&amp;gt;&lt;br /&gt;WHEN NOT MATCHED BY SOURCE THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;UPDATE or DELETE statement&amp;gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Example how to use MERGE statement is given below.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;You have stocks stored at Stock table here :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;CREATE TABLE Stock (Name varchar(10) primary key, Qty int);&lt;br /&gt;GO&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Insert into Stock VALUES (‘Indosat’,10000);&lt;br /&gt;Insert into Stock VALUES (‘BNI’,15000);&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Every day you trade stocks and those transactions are put into Trade table here :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Insert into Trade (Name varchar(10) primary key, Qty int);&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;For example, during a day, you sold 5000 Indosat stocks, bought 5000 BNI stocks, and bought new stocks of BPMIGAS and those are recorded into Trade table.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Insert into Trade VALUES (‘Indosat’,-5000);&lt;br /&gt;Insert into Trade VALUES (‘BNI’, 5000);&lt;br /&gt;Insert into Trade VALUES (‘BPMIGAS’,2000);&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;At the end of a day, you would like to update Stock table with transactions from Trade using MERGE statement with condition when new stock on Trade, they will be inserted into Stock table, when existing stock then they will be updated into Stock table. Here is MERGE query :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;MERGE Stock AS s&lt;br /&gt;USING Trade AS t&lt;br /&gt;ON s.Name = t.Name&lt;br /&gt;WHEN MATCHED THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;UPDATE SET Stock.Qty += Trade.Qty&lt;br /&gt;WHEN NOT MATCHED BY TARGET THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;INSERT VALUES (t.Name, t.Qty);&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;After above MERGE statement is run, rows on Stock table will be :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Name&lt;span style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Qty&lt;br /&gt;Indosat&lt;span style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;5000&lt;br /&gt;BNI&lt;span style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;20000&lt;br /&gt;BPMIGAS&lt;span style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;2000&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;You can write MERGE query here:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;MERGE Stock AS s&lt;br /&gt;USING Trade AS t&lt;br /&gt;ON s.Name = t.Name&lt;br /&gt;WHEN MATCHED THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;UPDATE SET Stock.Qty += Trade.Qty&lt;br /&gt;WHEN NOT MATCHED THEN&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;INSERT VALUES (t.Name, t.Qty);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:11pt;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;By default if you don’t specify BY SOURCE or BY TARGET on WHEN NOT MATCHED clause, it will be default to BY TARGET.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=452" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Viewing Big Data in Excel 2007</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/21/viewing-big-data-in-excel-2007.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/21/viewing-big-data-in-excel-2007.aspx</id><published>2009-07-20T23:43:00Z</published><updated>2009-07-20T23:43:00Z</updated><content type="html">&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;Viewing Big Data in Excel 2007&lt;/font&gt;&lt;/h2&gt;
&lt;h3 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="3"&gt;By : Kasim Wirama, MCITP, MCDBA&lt;/font&gt;&lt;/h3&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;SQL Server Integration Services (SSIS) is excellent ETL platform to do export import data from and to heterogeneous data source. In this posting, I would like to give my thought about exporting data into excel file as it is most popular alternatives besides flat file and it’s widely used as office spreadsheet application.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;Excel has great feature and user friendly capability but it’s has also limitation in terms of maximum 65,536 rows supported. In SSIS 2005 it has excel provider up to version 2003 so you will get hard limit to the maximum rows and in SSIS 2008 it has excel provider up to version 2007 so you will get soft limit to the maximum rows. If you use either SSIS 2005 or SSIS 2008, you may have 2 options to export rows larger than maximum limit. First option is to create custom data source provider as SSIS provides API to extend it. Second option is to export column delimited flat files. If you frequently export big rows into excel file, I suggest you to create custom excel file extension otherwise you can have second option.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;I discuss the second option. After you run export process into the delimited file; you can view them in excel 2007. Definitely excel 2003 or older version couldn’t show you whole data in one worksheet. First open your excel file. Then open tab delimited file by clicking at upper left corner and choose Open sub menu. &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;In open dialog menu, choose all file type and pick your column delimited file. After you click Open button, you will be presented to Text Import Wizard – Step 1 of 3. Choose Delimited option and go to Next button. On Step 2 of 3, choose delimited character and go to Next button. On last step (Step 3 of 3), you can define different data type for each column by clicking each column first and then choose data type in option region (Column Data Format).&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:11pt;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;Excel 2007 offers great flexibility than previous version. If you have big rows beyond 65,536 rows, Excel 2007 could display them perfectly.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=451" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>SQL Server 2008 PowerShell</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/10/sql-server-2008-powershell.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/10/sql-server-2008-powershell.aspx</id><published>2009-07-09T13:14:00Z</published><updated>2009-07-09T13:14:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;
 
  
  
 

 
  Normal
  0
  
  
  
  
  false
  false
  false
  
  EN-US
  X-NONE
  X-NONE
  
   
   
   
   
   
   
   
   
   
   
   
  
  
   
   
   
   
   
   
   
   
   
   
   
  

 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 




 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:&amp;quot;Table Normal&amp;quot;;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:&amp;quot;&amp;quot;;
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;}



&lt;/p&gt;&lt;h2 style="text-align:center;" align="center"&gt;SQL Server 2008 PowerShell&lt;/h2&gt;

&lt;h2 style="text-align:center;" align="center"&gt;By : Kasim Wirama, MCDBA, MCITP&lt;/h2&gt;

&lt;p class="MsoNormal" style="text-align:justify;"&gt;PowerShell is next generation
scripting language after MS-DOS. Microsoft supports software products with
PowerShell. PowerShell is built on .NET 2.0 frameworks. It supports all DOS
commands and could run any scripts written in other language. Here are terminology
in PowerShell.&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpFirst" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;1.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;CmdLet&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;Is command name.
Naming convention for CmdLet is verb-noun. For example : get-command&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;2.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Script&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;PowerShell
extension is ps1. To run PowerShell script, simply specify power shell
scripting file.&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;3.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Pipeline&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;Is introduced by
| sign, which separates series of commands (cmdlet). Output of current cmdlet
would be input for next cmdlets.&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;4.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Provider&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;Is type of data
store where user is presented with format similar to file system. For SQL
Server provider, hierarchy SQL Server is in file system format, as you usually
navigate in MS-DOS prompt.&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;5.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Snap-in&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;Is poweshell
extension, which usually comes in DLL written in .NET programming language.
Usually snap-in consists additional cmdlet or provider.&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpLast" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;6.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Aliases&lt;br /&gt;
is shorter name of cmdlet command.&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-left:0.25in;text-align:justify;"&gt;Powershell
implementasion in SQL Server 2008 is called SQL Server Powershell. Command line
for SQL Server 2008 PowerShell is sqlps. You can type sqlps in DOS-prompt or
right click on any database object in object explorer of SSMS SQL Server 2008.&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-left:0.25in;text-align:justify;"&gt;After you
successfully entered into sqlps provider environment, type dir command then SQL
PowerShell returns 4 items, they are : SQL Server Database Engine, SQL Server
Policy Management, SQL Server Registrations, and SQL Server Data Collection.
All your SQL Server instances are located inside SQL Server Database Engine.
You can navigate into SQL Server Database Engine item, by issuing cd command
(Cd SQL) then press enter. Then you will be presented to your machine. Your SQL
instance are inside your machine name directory, so issue cd &amp;lt;your machine
name&amp;gt; command. Now you are in beginning of your SQL Server instance. It
displays file system hierarchy format, so it’s as convenient as navigating in
DOS file system. Try yourself and tell me your experience in using SQL
PowerShell.&lt;/p&gt;

&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=442" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Concatenate Multi Row Column Value into One Row</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/10/concatenate-multi-row-column-value-into-one-row.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/07/10/concatenate-multi-row-column-value-into-one-row.aspx</id><published>2009-07-09T04:56:00Z</published><updated>2009-07-09T04:56:00Z</updated><content type="html">&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;Concatenate Multi Row Column Value into One Row&lt;/font&gt;&lt;/h2&gt;
&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;By : Kasim Wirama, MCDBA, MCITP&lt;/font&gt;&lt;/h2&gt;
&lt;p style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Sometimes you need concatenate multiple rows into 1 string value separated by delimiter (usually comma). For example to get orderdescription from same customerid like the example below :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Declare @order table (orderid int, custid int, orderdescription varchar(50));&lt;br /&gt;insert into @order values (1,676,’order by CustA’);&lt;br /&gt;insert into @order values (2,676,’order by CustB’); &lt;br style="mso-special-character:line-break;" /&gt;&lt;br style="mso-special-character:line-break;" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Expected outcome is &lt;/font&gt;&lt;/p&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Order by CustA, order by CustB&lt;/font&gt;&lt;/font&gt;&lt;/b&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;SQL Server 2005 onwards comes up with XML features, one of them is FOR XML PATH, here is the query to get desired output :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Declare @list varchar(max);&lt;br /&gt;set @list = stuff (&lt;br /&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(select ‘, ‘ + orderdescription as [text()]&lt;br /&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;from @order&lt;br /&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;when custid = 676&lt;br /&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;FOR XML PATH(‘’)&lt;br /&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;)&lt;br /&gt;&lt;span style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;, 1, 2, ‘’);&lt;br /&gt;select @list;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;It looks okay, until there is evil input into @order table like below :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;insert into @order values (2,676,’order by CustA &amp;amp; order by CustB’);&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;rerun the FOR XML PATH query again, the expected outcome is &lt;/font&gt;&lt;/p&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;order by CustA, order by CustB, order by CustA &amp;amp;amp; order by CustB&lt;/font&gt;&lt;/font&gt;&lt;/b&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;If you notice ‘&lt;b style="mso-bidi-font-weight:normal;"&gt;&amp;amp;&lt;/b&gt;’ is changed by XML PATH clause into ‘&lt;b style="mso-bidi-font-weight:normal;"&gt;&amp;amp;amp;&lt;/b&gt;’&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;The same thing would happen if the column value contains any HTML preserved character such as &amp;lt;, and &amp;gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Better solution for reproducing single rows of concatenated values of rows is by using conventional one as following query below shown :&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:11pt;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;Declare @list varchar(max);&lt;br /&gt;set @list = ‘’;&lt;br /&gt;select @list = &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;case @list when ‘’ then orderdescription&lt;br /&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;else @list + ‘, ‘ + orderdescription&lt;br /&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;end&lt;br /&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;from @order&lt;br /&gt;&lt;span style="mso-tab-count:3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;when custid = 676;&lt;br /&gt;&lt;br /&gt;select @list;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=438" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Calculating Number of Hierarchy Level in Clustered Index</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/06/25/calculating-number-of-hierarchy-level-in-clustered-index.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/06/25/calculating-number-of-hierarchy-level-in-clustered-index.aspx</id><published>2009-06-25T00:18:00Z</published><updated>2009-06-25T00:18:00Z</updated><content type="html">&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;Calculating Number of Hierarchy Level in Clustered Index&lt;/font&gt;&lt;/h2&gt;
&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;By : Kasim Wirama, MCDBA, MCITP&lt;/font&gt;&lt;/h2&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;This posting, I would like to describe the way to calculate number of hierarchy level of an index in SQL Server. Before I delve into calculation discussion how to calculate index level, I describe index structure in SQL Server.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;In SQL Server Books Online, index structure (applies on both non-clustered and clustered index) forms b-tree. B-tree is balanced tree. Balanced tree is a tree where no leaf is much farther away from the root than any other leaf in the tree. Algorithmic background of the tree structure can be found at &lt;/font&gt;&lt;a href="http://www.nist.gov/dads/HTML/balancedtree.html"&gt;&lt;font face="Calibri" size="3"&gt;http://www.nist.gov/dads/HTML/balancedtree.html&lt;/font&gt;&lt;/a&gt;&lt;font face="Calibri" size="3"&gt; or you can read book titled “The Art of Computer Programming, Volume 3: Sorting and Searching (2&lt;sup&gt;nd&lt;/sup&gt; Edition) by Donald E. Knuth (Addison-Wesley Professional, 1998). Go back to tree structure discussion, the difference between non-clustered and clustered index lies to what data contains in leaf level (lowest level) of an index hierarchy. In clustered index, lowest level of index contains data itself, whereas it contains index key column and clustering key (in clustered index table) or row locater (in heap table). Heap table is a table that doesn’t have clustered index. What is clustering key? Clustering key is a clustered index that contains unique index key or if the index key is not unique, internally SQL Server will add uniquifier to make uniqueness of the index column, at the end clustered index is a unique index internally though its key column doesn’t appear unique.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;Structure of balanced tree contains root (only 1 page) at top level and subsequent lower levels (1 or more pages). For example there are 3 levels, i.e. : level1, level2, level3. Each records in level1 points to each page(s) in level2 and each rows in level2 will point to each page(s). In same level where there might be more than one pages (except level1), there is double linked list connecting one page to next page so that it is possible SQL Server parses from one page to other page at same level.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;To get information how many index level on existing index, you can query function INDEXPROPERTY with parameter IndexDepth. Type in books online regarding to INDEXPROPERTY function and you will get list of input parameter which one of them has description for IndexDepth. How about non existing index? You can still have a way to estimate how many level that a index would have by following the following calculation :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font face="Calibri" size="3"&gt;1.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri" size="3"&gt;Get information number of rows in a table. For example you have 1 million rows in orders table.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font face="Calibri" size="3"&gt;2.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri" size="3"&gt;Determine row size of a table. If there is variable length data type such as varchar/nvarchar; you probably need to estimate how many characters will occupy for length specified to corresponding variable those length data types. For example you assume 50% of column length is counted. And see whether the column is null, if yes, then add 1 bit column overhead. At the end of all columns size is determined, add 2 byte pointer overhead. That’s because there is 2 byte pointer located at the end of every page. For example, row size for order table is 200 byte.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font face="Calibri" size="3"&gt;3.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri" size="3"&gt;Determine page density. You will have your index has empty space so that it doesn’t fully fill up a page. You can refer page density to fill factor of an index, usually fill factor is 90%.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font face="Calibri" size="3"&gt;4.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri" size="3"&gt;Calculate the number of rows that could fit into one page, the formula is (page size – header size) * page density / row size. Page size in SQL Server is 8192 byte, header size is 96 byte, page density is 0.9 and row size is 200 byte. The floor result is 36.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font face="Calibri" size="3"&gt;5.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri" size="3"&gt;Calculate number of pages based on result on step 4, the formula is number of total rows divided by number of rows of each pages (1 million/36). The result is 27778 pages.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font face="Calibri" size="3"&gt;6.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri" size="3"&gt;That’s the lowest level, now go up the upper level. Calculate average row size of a page providing size of index key column. If index key column is datetime type so the size is 8 byte. If it is not unique then there is additional 4 byte size as uniquifier, 2 bytes pointer located at the end of a page, pointer for linked list is 6 bytes plus internal overhead is 5 bytes, so total is 25 bytes if the index column is not unique or 21 bytes is index column is unique. For example the orderdate column is not unique.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font face="Calibri" size="3"&gt;7.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri" size="3"&gt;Counter number of rows that fit in one page with same formula in point 4. The result is 291 rows per one page.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;font face="Calibri" size="3"&gt;8.&lt;/font&gt;&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri" size="3"&gt;To get number of levels above leaf level, you get it from formula ceiling (log 27778 / log 291) = 2.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="MARGIN:0in 0in 10pt 0.5in;TEXT-ALIGN:justify;"&gt;&lt;font face="Calibri" size="3"&gt;Total pages including leaf level is the previous result plus 1 (it is 3 for final result).&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:11pt;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;By getting know number of levels of a non-existing index, you will know the cost of index seeks. The cost equals to number of page it travels from root to required leaf level, whilst index scan will scan all leaf pages. The fewer pages it travels, the more efficient access method of a corresponding query is.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=416" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Eksplorasi Kebutuhan Bisnis dengan Transact SQL</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/04/21/eksplorasi-kebutuhan-bisnis-dengan-transact-sql.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/04/21/eksplorasi-kebutuhan-bisnis-dengan-transact-sql.aspx</id><published>2009-04-21T00:23:00Z</published><updated>2009-04-21T00:23:00Z</updated><content type="html">&lt;h1 style="MARGIN:24pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;span&gt;&lt;font face="Cambria" color="#365f91" size="5"&gt;Eksplorasi Kebutuhan Bisnis dengan Transact SQL&lt;/font&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Transact SQL memiliki kapabilitas query database relasional yang memiliki performance terbaik dalam hal akses data berbasis set oriented. Bila tertarik mengasah problem-problem dunia bisnis yang diterjemahkan ke dalam SQL, saya berikan kasus berikut ini.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Table Prefix barang (PrefixBarang)&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;table class="MsoTableGrid" style="BORDER-RIGHT:medium none;BORDER-TOP:medium none;BORDER-LEFT:medium none;BORDER-BOTTOM:medium none;BORDER-COLLAPSE:collapse;mso-border-alt:solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;" cellspacing="0" cellpadding="0" class="MsoTableGrid"&gt;

&lt;tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes;"&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:213.05pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;KodePrefixBarang&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:213.05pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Jenis&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:1;"&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:213.05pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;B01&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:213.05pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Biskuit&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:2;"&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:213.05pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;M01&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:213.05pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Mi Instan&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:3;mso-yfti-lastrow:yes;"&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:213.05pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;R01&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:213.05pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Roti&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Table lookup&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;table class="MsoTableGrid" style="BORDER-RIGHT:medium none;BORDER-TOP:medium none;BORDER-LEFT:medium none;BORDER-BOTTOM:medium none;BORDER-COLLAPSE:collapse;mso-border-alt:solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;" cellspacing="0" cellpadding="0" class="MsoTableGrid"&gt;

&lt;tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes;"&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:105.3pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;KodeLookup&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:105.7pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;LokasiPabrik&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Biskuit&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Mi Instant&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Roti&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:1;"&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:105.3pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;A&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:105.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Karawang&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;√&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;√&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:2;"&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:105.3pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;B&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:105.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Bandung&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;√&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:3;mso-yfti-lastrow:yes;"&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:105.3pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;C&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:105.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;Cimahi&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;PADDING-LEFT:5.4pt;BORDER-LEFT-COLOR:#ece9d8;PADDING-BOTTOM:0in;WIDTH:71.7pt;BORDER-TOP-COLOR:#ece9d8;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;√&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Kode barang terdiri atas kombinasi PrefixBarang dan lookup, seperti :&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;B01A&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;B01B&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;B01C&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;M01A&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;M01B&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;M01C&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;R01A&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;R01C&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Dari setiap kode barang diatas dikehendaki informasi lokasi pabrik sehingga&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;B01A &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Wingdings;mso-ascii-font-family:&amp;#39;Times New Roman&amp;#39;;mso-hansi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt; Karawang&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;B01B &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Wingdings;mso-ascii-font-family:&amp;#39;Times New Roman&amp;#39;;mso-hansi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt; NULL&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;B01C &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Wingdings;mso-ascii-font-family:&amp;#39;Times New Roman&amp;#39;;mso-hansi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt; NULL&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;M01A &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Wingdings;mso-ascii-font-family:&amp;#39;Times New Roman&amp;#39;;mso-hansi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt; NULL&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;M01B &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Wingdings;mso-ascii-font-family:&amp;#39;Times New Roman&amp;#39;;mso-hansi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt; Bandung&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;M01C &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Wingdings;mso-ascii-font-family:&amp;#39;Times New Roman&amp;#39;;mso-hansi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt; NULL&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;R01A &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Wingdings;mso-ascii-font-family:&amp;#39;Times New Roman&amp;#39;;mso-hansi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt; NULL&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt;R01C &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:Wingdings;mso-ascii-font-family:&amp;#39;Times New Roman&amp;#39;;mso-hansi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman"&gt; Cimahi&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Diminta transact SQL dengan diketahui input kode prefix barang dan kode lookup untuk mendapatkan lokasi pabrik.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Yang jawabannya sesuai dengan yang diminta, saya kirimkan CD SQL Server 2008.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=378" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Detailed Training Materials of SQL Server 2008</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/04/21/detailed-training-materials-of-sql-server-2008.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/04/21/detailed-training-materials-of-sql-server-2008.aspx</id><published>2009-04-20T06:53:00Z</published><updated>2009-04-20T06:53:00Z</updated><content type="html">&lt;h1 style="MARGIN:24pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;span style="FONT-SIZE:18pt;COLOR:#365f91;mso-bidi-font-family:Arial;mso-ascii-font-family:Cambria;mso-hansi-font-family:Cambria;mso-ansi-language:EN-AU;"&gt;&lt;font face="Cambria"&gt;Detailed Training Materials of SQL Server 2008&lt;/font&gt;&lt;/span&gt;&lt;/h1&gt;&lt;span style="FONT-SIZE:12pt;COLOR:black;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-ansi-language:EN-AU;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:black;mso-ansi-language:EN-AU;"&gt;&lt;font face="Calibri" size="3"&gt;David Lean, a Microsoft SQL guru, has posted detailed training material of SQL Server 2008. For detail, please visit his blog at : &lt;/font&gt;&lt;a href="http://blogs.msdn.com/davidlean/archive/2009/04/16/sql-server-2008-jumpstart-materials-very-detailed-training-now-free-to-download.aspx"&gt;&lt;font face="Calibri" size="3"&gt;http://blogs.msdn.com/davidlean/archive/2009/04/16/sql-server-2008-jumpstart-materials-very-detailed-training-now-free-to-download.aspx&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:black;FONT-FAMILY:&amp;#39;Times New Roman&amp;#39;,&amp;#39;serif&amp;#39;;mso-ansi-language:EN-AU;"&gt;&lt;font size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;p&gt;&lt;span style="FONT-SIZE:11pt;COLOR:black;FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-AU;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;I have explored the training material. I can say that it is comprehensive and detailed training. &lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;Take your time to learn great features of SQL Server 2008 through the training material.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=377" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Launch of First Ebook from SQL Server Indo</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/04/01/launch-of-first-ebook-from-sql-server-indo.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/04/01/launch-of-first-ebook-from-sql-server-indo.aspx</id><published>2009-03-31T20:32:00Z</published><updated>2009-03-31T20:32:00Z</updated><content type="html">&lt;h1 style="TEXT-ALIGN:center;MARGIN:24pt 0in 0pt;" align="center"&gt;&lt;font color="#365f91" size="5" face="Cambria"&gt;Launch of First Ebook from SQL Server Indo&lt;/font&gt;&lt;/h1&gt;
&lt;p style="TEXT-ALIGN:justify;MARGIN:10pt 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;With pride, we (I, Hendrik and Yudhi) announce launching of SQL Server 2008 Business Intelligence ebook. For link to download, please go to &lt;/font&gt;&lt;a href="http://sqlserver-indo.org/files/folders/ebook/entry308.aspx" target="_blank"&gt;&lt;font color="#800080" size="3" face="Calibri"&gt;http://sqlserver- indo.org/ files/folders/ ebook/entry308. aspx&lt;/font&gt;&lt;/a&gt;&lt;font size="3" face="Calibri"&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p style="TEXT-ALIGN:justify;MARGIN:10pt 0in 0pt;" class="MsoNormal"&gt;&lt;span style="mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=310" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Implementing Access to SQL Server Analysis Services 2008 by Parameterization feature on SQL Server Reporting Services 2008</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/02/17/implementing-access-to-sql-server-analysis-services-2008-by-parameterization-feature-on-sql-server-reporting-services-2008.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/02/17/implementing-access-to-sql-server-analysis-services-2008-by-parameterization-feature-on-sql-server-reporting-services-2008.aspx</id><published>2009-02-16T08:39:00Z</published><updated>2009-02-16T08:39:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;I upload &lt;a href="http://sqlserver-indo.org/files/folders/articles/entry240.aspx" target="_blank"&gt;article &lt;/a&gt;about business intelligence in SQL Server 2008, specifically accessing SQL Server Analysis Services 2008 from SQL Server Reporting Services 2008. Enjoy.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Kasim Wirama&lt;br /&gt;MCDBA, MCITP, SQL Server MVP.&lt;br /&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=241" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Enable File Stream on SQL Server 2008</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/02/15/enable-file-stream-on-sql-server-2008.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/02/15/enable-file-stream-on-sql-server-2008.aspx</id><published>2009-02-14T11:21:00Z</published><updated>2009-02-14T11:21:00Z</updated><content type="html">&lt;h1 style="text-align:center;" align="center"&gt;Enable File Stream on SQL Server
2008&lt;/h1&gt;

&lt;h2 style="text-align:center;" align="center"&gt;By : Kasim Wirama, MCDBA, MCITP&lt;/h2&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal" style="text-align:justify;"&gt;SQL Server 2008 has filestream
feature. It marries best world power of file management by windows file system
and database transaction atomicity. If you have LOB files such as documents,
images, big size file audio/video, filestream options offers best performance
and ease of administration. If you haven’t enabled filestream feature during installation,
you are still able to enable it during post installation.&lt;/p&gt;

&lt;p class="MsoNormal" style="text-align:justify;"&gt;Here is steps how to enable file
stream :&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpFirst" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;1.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Open
SQL Server Configuration Manager (Start &amp;gt; Programs &amp;gt; Microsoft SQL Server
2008 &amp;gt; Configuration Tools &amp;gt; SQL Server Configuration Manager).&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;Note : SQL
Server Configuration Manager is the replacement of SQL Server Control Manager
of SQL Server 2000.&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;2.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Go
to SQL Server Services node, and select SQL Server instance that you want to
enable filestream feature.&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;3.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Double
click on the SQL Server instance, it display SQL Server &amp;lt;instance&amp;gt;
Properties dialog box. By default if you have only one instance, the value is
MSSQLSERVER. But in my computer, I enable it for delta\SQL2008_1 named
instance.&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;&lt;span&gt;
 
 
  
  
  
  
  
  
  
  
  
  
  
  
 
 
 

 
&lt;img src="http://sqlserver-indo.org/blogs/kasimwirama/Enable%20File%20Stream%20on%20SQL%20Server%202008/enable%20sql%20server%20service.JPG" width="1280" align="middle" height="774" alt="" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;span&gt;&lt;span&gt;4.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Click
FILESTREAM tab, and select checkboxes to enable FILESTREAM, enter share name
for files.&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;text-indent:-0.25in;"&gt;&lt;img src="http://sqlserver-indo.org/blogs/kasimwirama/Enable%20File%20Stream%20on%20SQL%20Server%202008/enable%20sql%20server%20service2.JPG" width="395" align="middle" height="442" alt="" /&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpMiddle" style="text-align:justify;"&gt;&lt;span&gt;
 
&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoListParagraphCxSpLast"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal" style="text-align:justify;"&gt;Now your SQL Server has
filestream-enabled feature. &lt;span style="font-family:Wingdings;"&gt;&lt;span&gt;J&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="text-align:justify;"&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=238" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Read the Most Updated Knowledge of SQL Server 2008 From SQL Server Internals Guru, Kalen Delaney</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/02/05/read-the-most-updated-knowledge-of-sql-server-2008-from-sql-server-internals-guru-kalen-delaney.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/02/05/read-the-most-updated-knowledge-of-sql-server-2008-from-sql-server-internals-guru-kalen-delaney.aspx</id><published>2009-02-04T22:59:00Z</published><updated>2009-02-04T22:59:00Z</updated><content type="html">&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;Read the Most Updated Knowledge of SQL Server 2008&lt;/font&gt;&lt;/h2&gt;
&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;From SQL Server Internals Guru, Kalen Delaney&lt;/font&gt;&lt;/h2&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Kalen Delaney, an expert of SQL Server, is a regular contributor of SQL Server Magazine and author for Inside SQL Server series. Recent book is SQL Server 2008 Internals. This book contains 2 parts.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Part 1 :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Heaps and B-trees&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Clustered indexes&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Nonclustered indexes&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Index internals&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Covering indexes and included columns&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Index metadata&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Fragmentation&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Rebuilding indexes&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Filtered indexes&lt;/font&gt;&lt;/p&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Part 2 :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Query processing overview&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Plan management and reuse&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Causes of recompilation&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Forcing recompilation&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Optimization and compilation hints&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Optimizer metadata&lt;/font&gt;&lt;/p&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;If you are interested to know inner working of SQL Server (is a foundation as true performance tuner), it is a good investment for your knowledge and stand out of crowd.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=231" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Backup and Restore master Database in SQL Server</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/02/05/backup-and-restore-master-database-in-sql-server.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/02/05/backup-and-restore-master-database-in-sql-server.aspx</id><published>2009-02-04T12:37:00Z</published><updated>2009-02-04T12:37:00Z</updated><content type="html">&lt;h2 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="4"&gt;Backup and Restore master Database in SQL Server&lt;/font&gt;&lt;/h2&gt;
&lt;h3 style="MARGIN:10pt 0in 0pt;TEXT-ALIGN:center;" align="center"&gt;&lt;font face="Cambria" color="#4f81bd" size="3"&gt;By : Kasim Wirama, MCDBA, MCITP, SQL Server MVP&lt;/font&gt;&lt;/h3&gt;
&lt;p&gt;&lt;font face="Calibri" size="3"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;SQL Server contains system databases. They are master, model, msdb, tempdb and distribution databases. Distribution databases exist only when you enable replication feature in your current SQL Server instance. A good backup and recovery plan includes backup for both user databases and system databases. The most important system database to restore is master database. &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Master database contains SQL Server system level configuration information, linked server configuration, SQL Server logins, Service broker endpoints, system stored procedure and system functions. Backing up master database in periodical basis or system configuration changes is recommended. To backup master database issue this statement :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;BACKUP DATABASE master&lt;br /&gt;TO DISK = ‘C:\master.bak’;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;In case your master database is corrupt, you need to restore master database. This restore statement wouldn’t work for master database :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;RESTORE DATABASE master&lt;br /&gt;FROM DISK = ‘C:\master.bak’;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;It fails because master database should be restore under offline mode on SQL Server wide setting. Go to configuration manager, click on SQL Service on left pane, and open Properties page of your SQL Server instance. Go to Advanced tab, in startup parameter you will find out location of data and log file of master database like sample below :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;-dF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\DATA\master.mdf ;-eF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\Log\ERRORLOG ;-lF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\DATA\mastlog.ldf;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Add –m switch for each of them, so final result would be :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;-dF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\DATA\master.mdf;-m ;-eF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\Log\ERRORLOG;-m ;-lF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\DATA\mastlog.ldf;-m;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Then, you click restart button on Log On tab of SQL Server properties page. After restarting, your SQL Server is under single user mode. Open only 1 window (query analyzer or SQL Server Management Studio (SSMS)) and restore master database with TSQL statement here :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;RESTORE DATABASE master&lt;br /&gt;FROM DISK = ‘C:\master.bak’&lt;br /&gt;WITH REPLACE;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;After you have restore master database, change back parameter below to original one.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;-dF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\DATA\master.mdf;-m ;-eF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\Log\ERRORLOG;-m ;-lF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\DATA\mastlog.ldf;-m;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Original one :&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;-dF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\DATA\master.mdf ;-eF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\Log\ERRORLOG ;-lF:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008_1\MSSQL\DATA\mastlog.ldf;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Restart your SQL Server to make it multi user mode again.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;Now your master database has successfully been recovered.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=230" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry><entry><title>Kinds of Storage Testing in SQL Server</title><link rel="alternate" type="text/html" href="http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/01/29/kinds-of-storage-testing-in-sql-server.aspx" /><id>http://sqlserver-indo.org/blogs/kasimwirama/archive/2009/01/29/kinds-of-storage-testing-in-sql-server.aspx</id><published>2009-01-28T23:18:00Z</published><updated>2009-01-28T23:18:00Z</updated><content type="html">&lt;h2 style="MARGIN:12pt 0in 3pt;TEXT-ALIGN:center;" align="center"&gt;&lt;span&gt;&lt;em&gt;Kinds of Storage Testing in SQL Server&lt;/em&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h3 style="MARGIN:12pt 0in 3pt;TEXT-ALIGN:center;" align="center"&gt;&lt;span style="FONT-SIZE:10pt;"&gt;By : Kasim Wirama, MCDBA, MCITP, MVP SQL Server&lt;/span&gt;&lt;/h3&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Before a new database is deployed into production server, it is strongly suggested that storage of the server box is tested against performance perspective to know how far the storage capability to handle normal load and under heavy load. There are 3 kinds of test, i.e. performance test, stress test and real life performance.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Performance test is a test to some or all database objects to get how fast a thing gets done. Sometimes performance test is more like stress test but the objective between them are different. In performance test, the objective is how fast you can get something done, not how many you have it done.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Stress test is used to get information in what extent a database server could hold up for concurrent request. Stress test could be said parallel test while performance test is called sequential test. Result correctness would be in consideration when doing both kind of test.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;Real life performance test is a mixed test between performance test and stress test. Usually use case is used to get information for the test. What is difference between real life performance test and 2 previous tests? Real life performance refers to actual unit of works a user does while stress/performance test refers to smaller server subsystem such as single disk’s I/O or few disk I/O’s together. Talking about use case, you can devise what kind operation might be involved whether they are random/sequential read or random/sequential write for each activities in a use case. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;For example of sequence of customer billing info activities in a use case:&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ol style="MARGIN-TOP:0in;"&gt;
&lt;li class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;query customer for general info&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt 0.5in;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;operation : random/sequential read.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;ol style="MARGIN-TOP:0in;" start="2"&gt;
&lt;li class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;get customer detail info&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt 0.5in;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;operation : random/sequential read&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;ol style="MARGIN-TOP:0in;" start="3"&gt;
&lt;li class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;get customer billing summary&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt 0.5in;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;operation : random/sequential read&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;ol style="MARGIN-TOP:0in;" start="4"&gt;
&lt;li class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;get customer billing history&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt 0.5in;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;operation : random/sequential read&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; 
&lt;ol style="MARGIN-TOP:0in;" start="5"&gt;
&lt;li class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt;TEXT-ALIGN:justify;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;update customer data&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p class="MsoNormal" style="TEXT-JUSTIFY:inter-ideograph;MARGIN:0in 0in 0pt 0.5in;TEXT-ALIGN:justify;"&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;operation : random write&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span&gt;&lt;font face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;img src="http://sqlserver-indo.org/aggbug.aspx?PostID=226" width="1" height="1"&gt;</content><author><name>kasim.wirama</name><uri>http://sqlserver-indo.org/members/kasim.wirama.aspx</uri></author><category term="SQL Server" scheme="http://sqlserver-indo.org/blogs/kasimwirama/archive/tags/SQL+Server/default.aspx" /></entry></feed>