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

<channel>
	<title>I&#039;m CaLendarW Blog &#187; database</title>
	<atom:link href="http://wongkalun.idv.hk/category/computer-science/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://wongkalun.idv.hk</link>
	<description>Put the technology in correct places</description>
	<lastBuildDate>Sun, 18 Apr 2010 16:19:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>MsSQL &#8211; Identity Generator</title>
		<link>http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/</link>
		<comments>http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 15:24:39 +0000</pubDate>
		<dc:creator>calendarw</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[error handling]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://wongkalun.idv.hk/?p=629</guid>
		<description><![CDATA[MsSQL 內既 Identity Generator, 雖然被發現當 Table 儲存超過一百萬行時, 由 SELECT @@Identity 或者 SELECT SCOPE_IDENTITY() 會存在 Return 值錯誤既問題, 但經過呢個幾月既開發都未出現問題. 係 MsSQL 入面, 新增 Record 時主要提取 Primary Key 既方法主要有 @@IDENTITY, SCOPE_IDENTY() 同 IDENT_CURRENT(&#8216;table_name&#8217;) 三種: @@IDENTITY 使用 @@IDENTITY 會 Return 當前 Session 任何 Table 最後生產的 Primary Key, 如果 Insert statement 運行後如果有任何 Trigger 中會 Insert 在其他 Table 的話, @@IDENTITY 就會變得不準確. [...]]]></description>
			<content:encoded><![CDATA[<p>MsSQL 內既 Identity Generator, 雖然被發現當 Table 儲存超過一百萬行時, 由 SELECT @@Identity 或者 SELECT SCOPE_IDENTITY() 會存在 Return 值錯誤既問題, 但經過呢個幾月既開發都未出現問題.</p>
<p>係 MsSQL 入面, 新增 Record 時主要提取 Primary Key 既方法主要有 @@IDENTITY, SCOPE_IDENTY() 同 IDENT_CURRENT(&#8216;table_name&#8217;) 三種:</p>
<p><strong>@@IDENTITY</strong><br />
使用 @@IDENTITY 會 Return 當前 Session 任何 Table 最後生產的 Primary Key, 如果 Insert statement 運行後如果有任何 Trigger 中會 Insert 在其他 Table 的話, @@IDENTITY 就會變得不準確.</p>
<p><strong>SCOPE_IDENTY()</strong><br />
使用 SCOPE_IDENTY() 會 Return 當前 Scope 內確實 Insert 左既 Primary Key, 就算有任何 Trigger 在背後運行都不會有任何影響, 係一個最好既選擇.  不過經由 MS Connect 入面既 <a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=328811">Feedback</a> 顯示, Table 被新增至一百萬行後, Return Value 有可以會籨 1 開始數起, 這問題由 MS 回應既答案中回答到已增加到它們的 Bug tracking database 中.</p>
<p><strong>IDENT_CURRENT(&#8216;table_name&#8217;)</strong><br />
而 IDENT_CURRENT(&#8216;table_name&#8217;) 會 Return 指定 Table 最後生產出來的 Identity, 由於它不會理會任何 Scope 或者 Session, 當有多於一個 Scope 或者 Session 運行時便有機會出現不準確既問題.</p>
<p>因此, 在以上三個尋找 IDENTITY 既方法中, 並沒有一個能在任何環境下百分百準確既方法, 所以在 MsSQL 使用 Identity Generator 便會有潛在問題既可能性, 因此在 deploy 前應該對 Database 作詳細測試, 已確定當前既環境設定正確.</p>
<p>再者, Identity Generator 亦開始慢慢地被其他類型既方案取代, 例如 <a href="http://en.wikipedia.org/wiki/Globally_Unique_Identifier">GUID</a>, Hi/Lo or UUID 等等.</p>
<p>正如之前 <a href="http://wongkalun.idv.hk/2009/06/15/software-engineering-does-not-equal-computer-science/">CS != SE</a> 文章內所講, Technology 其實永遠唔會有錯, 錯就只會錯在未能正確使用它們既人, 而軟件其中一個用途就係用來避免人們使用犯錯, 所以在程式篇寫時應該以不同既設定技巧及文檔來避免人們使用錯誤, 那軟件才容易正確地被使用!!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/&amp;title=MsSQL+-+Identity+Generator" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/&amp;title=MsSQL+-+Identity+Generator" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/&amp;title=MsSQL+-+Identity+Generator&amp;desc=MsSQL%20%E5%85%A7%E6%97%A2%20Identity%20Generator%2C%20%E9%9B%96%E7%84%B6%E8%A2%AB%E7%99%BC%E7%8F%BE%E7%95%B6%20Table%20%E5%84%B2%E5%AD%98%E8%B6%85%E9%81%8E%E4%B8%80%E7%99%BE%E8%90%AC%E8%A1%8C%E6%99%82%2C%20%E7%94%B1%20SELECT%20%40%40Identity%20%E6%88%96%E8%80%85%20SELECT%20SCOPE_IDENTITY%28%29%20%E6%9C%83%E5%AD%98%E5%9C%A8%20Return%20%E5%80%BC%E9%8C%AF%E8%AA%A4%E6%97%A2%E5%95%8F%E9%A1%8C%2C%20%E4%BD%86%E7%B6%93%E9%81%8E%E5%91%A2%E5%80%8B%E5%B9%BE%E6%9C%88%E6%97%A2%E9%96%8B%E7%99%BC%E9%83%BD%E6%9C%AA%E5%87%BA%E7%8F%BE%E5%95%8F%E9%A1%8C.%0D%0A%0D%0A%E4%BF%82%20MsSQL%20%E5%85%A5%E9%9D%A2%2C%20%E6%96%B0%E5%A2%9E%20Record%20%E6%99%82%E4%B8%BB%E8%A6%81%E6%8F%90%E5%8F%96%20Primary%20Key%20%E6%97%A2%E6%96%B9%E6%B3%95%E4" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/&amp;bm_description=MsSQL+-+Identity+Generator&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/&amp;title=MsSQL+-+Identity+Generator" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/&amp;title=MsSQL+-+Identity+Generator" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/&amp;title=MsSQL+-+Identity+Generator" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=MsSQL+-+Identity+Generator+-+http://bit.ly/bfdfwd&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>




		<!-- Added by WP-DragToShare-eXtended Plugin -->
		<script type="text/javascript">
			dtsv.dtse_post_629_permalink = 'http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/';
			dtsv.dtse_post_629_title = 'MsSQL – Identity Generator';
		</script>
		<!-- End of WP-DragToShare-eXtended Plugin -->]]></content:encoded>
			<wfw:commentRss>http://wongkalun.idv.hk/2009/07/07/mssql-identity-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Control of Duplication</title>
		<link>http://wongkalun.idv.hk/2009/05/22/control-of-duplication/</link>
		<comments>http://wongkalun.idv.hk/2009/05/22/control-of-duplication/#comments</comments>
		<pubDate>Thu, 21 May 2009 16:20:46 +0000</pubDate>
		<dc:creator>calendarw</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[duplication]]></category>

		<guid isPermaLink="false">http://wongkalun.idv.hk/?p=540</guid>
		<description><![CDATA[近期做緊 Application to Database 呢部份, 開始對 Analysis Patterns 一書中既 Knowledge Level 同 Operation Level 多左理解, 除此之外, 仲開始感受既點樣控制重覆!! Duplication, 係 Program 入面係理應避免的, 正如見到重覆既 Code 就應該進行重構一樣, 但在 Database 層面上既管理又可能係另一種講法. 係 Knowledge Level 入面, 儲存既資料應該避免重覆, 因為所做既係最新既資訊, 以最實時既資訊去處理日常既運作, 雖然用既係最新既資訊, 但儲存落 Database 入面就可能要將所有有關既 Value Object 儲存埋, 因為往後既日子如果 Knowledge Level 有所改變, 亦唔應該影響到 Database 入面 Operation Level 完成品既歷史, 方面了解當時既情況, 等同於 Data Mining [...]]]></description>
			<content:encoded><![CDATA[<p>近期做緊 Application to Database 呢部份, 開始對 <a href="http://www.amazon.com/Analysis-Patterns-Reusable-Addison-Wesley-Technology/dp/0201895420">Analysis Patterns</a> 一書中既 Knowledge Level 同 Operation Level 多左理解, 除此之外, 仲開始感受既點樣控制重覆!! </p>
<p>Duplication, 係 Program 入面係理應避免的, 正如見到重覆既 Code 就應該進行重構一樣, 但在 Database 層面上既管理又可能係另一種講法.  係 Knowledge Level 入面, 儲存既資料應該避免重覆, 因為所做既係最新既資訊, 以最實時既資訊去處理日常既運作, 雖然用既係最新既資訊, 但儲存落 Database 入面就可能要將所有有關既 Value Object 儲存埋, 因為往後既日子如果 Knowledge Level 有所改變, 亦唔應該影響到 Database 入面 Operation Level 完成品既歷史, 方面了解當時既情況, 等同於 Data Mining 一樣, 做既唔係避免重覆, 而係有必要地控制重覆, 呢個就係 Database Design 入面一個重要既地方!!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://wongkalun.idv.hk/2009/05/22/control-of-duplication/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/&amp;title=Control+of+Duplication" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/&amp;title=Control+of+Duplication" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/&amp;title=Control+of+Duplication&amp;desc=%E8%BF%91%E6%9C%9F%E5%81%9A%E7%B7%8A%20Application%20to%20Database%20%E5%91%A2%E9%83%A8%E4%BB%BD%2C%20%E9%96%8B%E5%A7%8B%E5%B0%8D%20Analysis%20Patterns%20%E4%B8%80%E6%9B%B8%E4%B8%AD%E6%97%A2%20Knowledge%20Level%20%E5%90%8C%20Operation%20Level%20%E5%A4%9A%E5%B7%A6%E7%90%86%E8%A7%A3%2C%20%E9%99%A4%E6%AD%A4%E4%B9%8B%E5%A4%96%2C%20%E4%BB%B2%E9%96%8B%E5%A7%8B%E6%84%9F%E5%8F%97%E6%97%A2%E9%BB%9E%E6%A8%A3%E6%8E%A7%E5%88%B6%E9%87%8D%E8%A6%86%21%21%20%0D%0A%0D%0ADuplication%2C%20%E4%BF%82%20Program%20%E5%85%A5%E9%9D%A2%E4%BF%82%E7%90%86%E6%87%89%E9%81%BF%E5%85%8D%E7%9A%84%2C%20%E6%AD%A3%E5%A6%82%E8%A6%8B%E5%88%B0%E9%87%8D%E8%A6%86%E6%97%A2%20Code%20%E5%B0%B1%E6%87%89%E8%A9%B2%E9%80%B2%E8%A1%8C%E9%87%8D%E6%A7%8B%E4%B8%80%E6%A8" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/&amp;bm_description=Control+of+Duplication&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/&amp;title=Control+of+Duplication" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/&amp;title=Control+of+Duplication" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/&amp;title=Control+of+Duplication" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://wongkalun.idv.hk/2009/05/22/control-of-duplication/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Control+of+Duplication+-+http://bit.ly/9r1kLD&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>




		<!-- Added by WP-DragToShare-eXtended Plugin -->
		<script type="text/javascript">
			dtsv.dtse_post_540_permalink = 'http://wongkalun.idv.hk/2009/05/22/control-of-duplication/';
			dtsv.dtse_post_540_title = 'Control of Duplication';
		</script>
		<!-- End of WP-DragToShare-eXtended Plugin -->]]></content:encoded>
			<wfw:commentRss>http://wongkalun.idv.hk/2009/05/22/control-of-duplication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rebuild Index on MsSQL</title>
		<link>http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/</link>
		<comments>http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 15:57:45 +0000</pubDate>
		<dc:creator>calendarw</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://wongkalun.idv.hk/?p=501</guid>
		<description><![CDATA[今日要對現有既 Table 做 Performance Testing, 但因為要 join 太多既 Table, 搜尋一個要 join 4 個 Table 先拎到想要既 &#8220;一隻&#8221; Record 既時間竟然要 11 秒, 可想而知個 Table Size 有幾大吧 (其實七位數字既 Record Count 啫, 而 where case 只有兩個用 &#8216;=&#8217; 既 criteria, 而且所有 Record 只能 insert, 不能 delete). 經過我 rebuild 過接近 10 個已有既 index 之後 (等了好幾分鐘), 搜尋時間減少至只需 5 秒&#8230; 以下係 mssql 2005 [...]]]></description>
			<content:encoded><![CDATA[<p>今日要對現有既 Table 做 Performance Testing, 但因為要 join 太多既 Table, 搜尋一個要 join 4 個 Table 先拎到想要既 &#8220;一隻&#8221; Record 既時間竟然要 11 秒, 可想而知個 Table Size 有幾大吧 (其實七位數字既 Record Count 啫, 而 where case 只有兩個用 &#8216;=&#8217; 既 criteria, 而且所有 Record 只能 insert, 不能 delete).</p>
<p>經過我 rebuild 過接近 10 個已有既 index 之後 (等了好幾分鐘), 搜尋時間減少至只需 5 秒&#8230;</p>
<p>以下係 mssql 2005 下 rebuild index 既一個 statement 既例子</p>
<pre class="brush: sql;">ALTER INDEX IX_tblMaster ON tblMaster REBUILD;</pre>
<p>IX_tblMaster 係 index 名<br />
tblMaster 係 table 名</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/&amp;title=Rebuild+Index+on+MsSQL" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/&amp;title=Rebuild+Index+on+MsSQL" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/&amp;title=Rebuild+Index+on+MsSQL&amp;desc=%E4%BB%8A%E6%97%A5%E8%A6%81%E5%B0%8D%E7%8F%BE%E6%9C%89%E6%97%A2%20Table%20%E5%81%9A%20Performance%20Testing%2C%20%E4%BD%86%E5%9B%A0%E7%82%BA%E8%A6%81%20join%20%E5%A4%AA%E5%A4%9A%E6%97%A2%20Table%2C%20%E6%90%9C%E5%B0%8B%E4%B8%80%E5%80%8B%E8%A6%81%20join%204%20%E5%80%8B%20Table%20%E5%85%88%E6%8B%8E%E5%88%B0%E6%83%B3%E8%A6%81%E6%97%A2%20%22%E4%B8%80%E9%9A%BB%22%20Record%20%E6%97%A2%E6%99%82%E9%96%93%E7%AB%9F%E7%84%B6%E8%A6%81%2011%20%E7%A7%92%2C%20%E5%8F%AF%E6%83%B3%E8%80%8C%E7%9F%A5%E5%80%8B%20Table%20Size%20%E6%9C%89%E5%B9%BE%E5%A4%A7%E5%90%A7%20%28%E5%85%B6%E5%AF%A6%E4%B8%83%E4%BD%8D%E6%95%B8%E5%AD%97%E6%97%A2%20Record%20Count%20%E5%95%AB%2C%20%E8%80%8C%20where%20case%20%E5%8F%AA%E6%9C%89%E5%85%A9%E5%80%8B%E7%94%A8%20%27%3D%27%20%E6" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/&amp;bm_description=Rebuild+Index+on+MsSQL&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/&amp;title=Rebuild+Index+on+MsSQL" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/&amp;title=Rebuild+Index+on+MsSQL" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/&amp;title=Rebuild+Index+on+MsSQL" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Rebuild+Index+on+MsSQL+-+http://bit.ly/doyYeg&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>




		<!-- Added by WP-DragToShare-eXtended Plugin -->
		<script type="text/javascript">
			dtsv.dtse_post_501_permalink = 'http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/';
			dtsv.dtse_post_501_title = 'Rebuild Index on MsSQL';
		</script>
		<!-- End of WP-DragToShare-eXtended Plugin -->]]></content:encoded>
			<wfw:commentRss>http://wongkalun.idv.hk/2009/04/28/rebuild-index-on-mssql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sqlcmd</title>
		<link>http://wongkalun.idv.hk/2009/04/27/sqlcmd/</link>
		<comments>http://wongkalun.idv.hk/2009/04/27/sqlcmd/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 14:41:22 +0000</pubDate>
		<dc:creator>calendarw</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[batch]]></category>

		<guid isPermaLink="false">http://wongkalun.idv.hk/?p=494</guid>
		<description><![CDATA[Project Development Phase 已經開始, 但因為部份 Design 未全面, 所以仲有好多 Drop Table, Create Table 及 Initialize Value 既動作要做, 因為係咁, 所以就上網搵左點樣在 command prompt 行 SQL file. Usage: Sqlcmd [-U login id] [-P password] [-S server] [-H hostname] [-E trusted connection] [-d use database name] [-l login timeout] [-t query timeout] [-h headers] [-s colseparator] [-w screen width] [-a [...]]]></description>
			<content:encoded><![CDATA[<p>Project Development Phase 已經開始, 但因為部份 Design 未全面, 所以仲有好多 Drop Table, Create Table 及 Initialize Value 既動作要做, 因為係咁, 所以就上網搵左點樣在 command prompt 行 SQL file.</p>
<blockquote><p>Usage: Sqlcmd [-U login id] [-P password] [-S server] [-H hostname] [-E trusted connection] [-d use database name] [-l login timeout]     [-t query timeout] [-h headers] [-s colseparator] [-w screen width] [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers] [-c cmdend] [-L list servers[clean output]] [-q "cmdline query"] [-Q "cmdline query" and exit] [-m errorlevel] [-V severitylevel] [-W remove trailing spaces] [-u unicode output] [-r[0|1] msgs to stderr] [-i inputfile] [-o outputfile] [-z new password] [-f <codepage> | i:<codepage>[,o:<codepage>]] [-Z new password and exit] [-k[1|2] remove[replace] control characters] [-y variable length type display width] [-Y fixed length type display width] [-p[1] print statistics[colon format]] [-R use client regional setting] [-b On error batch abort] [-v var = "value"...] [-A dedicated admin connection] [-X[1] disable commands, startup script, environment variables [and exit]] [-x disable variable substitution] [-? show syntax summary]</p></blockquote>
<p>而自己就寫左個 batch 係 rebuild database:</p>
<pre class="brush: bash;">
sqlcmd -U calendarw -P password -S 192.168.1.10 -d testing_database -i Drop_Table.sql
sqlcmd -U calendarw -P password -S 192.168.1.10 -d testing_database -i Create_Table.sql
sqlcmd -U calendarw -P password -S 192.168.1.10 -d testing_database -i Init_Default_Value.sql
</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://wongkalun.idv.hk/2009/04/27/sqlcmd/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://wongkalun.idv.hk/2009/04/27/sqlcmd/&amp;title=Sqlcmd" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://wongkalun.idv.hk/2009/04/27/sqlcmd/&amp;title=Sqlcmd" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://wongkalun.idv.hk/2009/04/27/sqlcmd/&amp;title=Sqlcmd&amp;desc=Project%20Development%20Phase%20%E5%B7%B2%E7%B6%93%E9%96%8B%E5%A7%8B%2C%20%E4%BD%86%E5%9B%A0%E7%82%BA%E9%83%A8%E4%BB%BD%20Design%20%E6%9C%AA%E5%85%A8%E9%9D%A2%2C%20%E6%89%80%E4%BB%A5%E4%BB%B2%E6%9C%89%E5%A5%BD%E5%A4%9A%20Drop%20Table%2C%20Create%20Table%20%E5%8F%8A%20Initialize%20Value%20%E6%97%A2%E5%8B%95%E4%BD%9C%E8%A6%81%E5%81%9A%2C%20%E5%9B%A0%E7%82%BA%E4%BF%82%E5%92%81%2C%20%E6%89%80%E4%BB%A5%E5%B0%B1%E4%B8%8A%E7%B6%B2%E6%90%B5%E5%B7%A6%E9%BB%9E%E6%A8%A3%E5%9C%A8%20command%20prompt%20%E8%A1%8C%20SQL%20file.%0D%0A%0D%0AUsage%3A%20Sqlcmd%20%5B-U%20login%20id%5D%20%5B-P%20password%5D%20%5B-S%20server%5D%20%5B-H%20hostname%5D" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://wongkalun.idv.hk/2009/04/27/sqlcmd/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://wongkalun.idv.hk/2009/04/27/sqlcmd/&amp;bm_description=Sqlcmd&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://wongkalun.idv.hk/2009/04/27/sqlcmd/&amp;title=Sqlcmd" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://wongkalun.idv.hk/2009/04/27/sqlcmd/&amp;title=Sqlcmd" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://wongkalun.idv.hk/2009/04/27/sqlcmd/&amp;title=Sqlcmd" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://wongkalun.idv.hk/2009/04/27/sqlcmd/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Sqlcmd+-+http://bit.ly/aVHwXr&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>




		<!-- Added by WP-DragToShare-eXtended Plugin -->
		<script type="text/javascript">
			dtsv.dtse_post_494_permalink = 'http://wongkalun.idv.hk/2009/04/27/sqlcmd/';
			dtsv.dtse_post_494_title = 'Sqlcmd';
		</script>
		<!-- End of WP-DragToShare-eXtended Plugin -->]]></content:encoded>
			<wfw:commentRss>http://wongkalun.idv.hk/2009/04/27/sqlcmd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Notes</title>
		<link>http://wongkalun.idv.hk/2008/03/14/oracle-notes/</link>
		<comments>http://wongkalun.idv.hk/2008/03/14/oracle-notes/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 02:35:07 +0000</pubDate>
		<dc:creator>calendarw</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://wongkalun.idv.hk/?p=30</guid>
		<description><![CDATA[Run shell in sqlplus: host ls -l or !ls -l Dummy Table Name: dual Get user error message in oracle: select * from user_errors; or show errors; ERROR: PLS-00201: identifier &#8216;SYS.DBMS_PIPE&#8217; must be declared Connect to the SYS schema and issue the following command: grant all on dbms_pipe to public; Subscribe to the comments for [...]]]></description>
			<content:encoded><![CDATA[<p>Run shell in sqlplus:</p>
<pre class="brush: sql;">host ls -l</pre>
<p>or</p>
<pre class="brush: sql;">!ls -l</pre>
<p>Dummy Table Name: dual</p>
<p>Get user error message in oracle:</p>
<pre class="brush: sql;">select * from user_errors;</pre>
<p>or</p>
<pre class="brush: sql;">show errors;</pre>
<p>ERROR: PLS-00201: identifier &#8216;SYS.DBMS_PIPE&#8217; must be declared<br />
Connect to the SYS schema and issue the following command:</p>
<pre class="brush: sql;">grant all on dbms_pipe to public;</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://wongkalun.idv.hk/2008/03/14/oracle-notes/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://wongkalun.idv.hk/2008/03/14/oracle-notes/&amp;title=Oracle+Notes" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://wongkalun.idv.hk/2008/03/14/oracle-notes/&amp;title=Oracle+Notes" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://wongkalun.idv.hk/2008/03/14/oracle-notes/&amp;title=Oracle+Notes&amp;desc=Run%20shell%20in%20sqlplus%3A%0D%0A%5Bsql%5Dhost%20ls%20-l%5B%2Fsql%5D%0D%0Aor%0D%0A%5Bsql%5D%21ls%20-l%5B%2Fsql%5D%0D%0ADummy%20Table%20Name%3A%20dual%0D%0A%0D%0AGet%20user%20error%20message%20in%20oracle%3A%0D%0A%5Bsql%5Dselect%20%2A%20from%20user_errors%3B%5B%2Fsql%5D%0D%0Aor%0D%0A%5Bsql%5Dshow%20errors%3B%5B%2Fsql%5D%0D%0AERROR%3A%20PLS-00201%3A%20identifier%20%27SYS.DBMS_PIPE%27%20must%20be%20declared%0D%0AConnect%20to%20the%20SYS%20schema%20and%20issue%20the" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://wongkalun.idv.hk/2008/03/14/oracle-notes/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://wongkalun.idv.hk/2008/03/14/oracle-notes/&amp;bm_description=Oracle+Notes&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://wongkalun.idv.hk/2008/03/14/oracle-notes/&amp;title=Oracle+Notes" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://wongkalun.idv.hk/2008/03/14/oracle-notes/&amp;title=Oracle+Notes" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://wongkalun.idv.hk/2008/03/14/oracle-notes/&amp;title=Oracle+Notes" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://wongkalun.idv.hk/2008/03/14/oracle-notes/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Oracle+Notes+-+http://bit.ly/9k1I02&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>




		<!-- Added by WP-DragToShare-eXtended Plugin -->
		<script type="text/javascript">
			dtsv.dtse_post_30_permalink = 'http://wongkalun.idv.hk/2008/03/14/oracle-notes/';
			dtsv.dtse_post_30_title = 'Oracle Notes';
		</script>
		<!-- End of WP-DragToShare-eXtended Plugin -->]]></content:encoded>
			<wfw:commentRss>http://wongkalun.idv.hk/2008/03/14/oracle-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
