<?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>追風箏的小孩 &#187; SQL</title>
	<atom:link href="http://m955.com/wp/archives/tag/sql/feed" rel="self" type="application/rss+xml" />
	<link>http://m955.com/wp</link>
	<description></description>
	<lastBuildDate>Thu, 03 Nov 2011 14:47:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server 中易混淆的數據類型</title>
		<link>http://m955.com/wp/archives/173</link>
		<comments>http://m955.com/wp/archives/173#comments</comments>
		<pubDate>Mon, 08 Dec 2008 15:27:39 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://m955.com/wp/archives/173</guid>
		<description><![CDATA[本文摘自「藍色理想」http://www.blueidea.com/tech/program/2004/1724.asp。
(1)char、varchar、text和nchar、nvarchar、ntext   char 和varchar的長度都在1到8000之間，它們的區別在於char是定長字符數據，而varchar是變長... ]]></description>
			<content:encoded><![CDATA[<p>本文摘自「藍色理想」<a href="http://www.blueidea.com/tech/program/2004/1724.asp。" target="_blank">http://www.blueidea.com/tech/program/2004/1724.asp。</a></p>
<p>(1)char、varchar、text和nchar、nvarchar、ntext   <br />char 和varchar的長度都在1到8000之間，它們的區別在於char是定長字符數據，而varchar是變長字符數據。所謂定長就是長度固定的，當輸入的數據長度沒有達到指定的長度時將自動以英文空格在其後面填充，使長度達到相應的長度；而變長字符數據則不會以空格填充。text存儲可變長度的非 Unicode數據，最大長度為2^31-1(2,147,483,647)個字符。 </p>
<p>後面三種數據類型和前面的相比，從名稱上看只是多了個字母&quot;n&quot;，它表示存儲的是Unicode數據類型的字符。寫過程序的朋友對Unicode應該很瞭解。字符中，英文字符只需要一個字節存儲就足夠了，但漢字眾多，需要兩個字節存儲，英文與漢字同時存在時容易造成混亂，Unicode字符集就是為瞭解決字符集這種不兼容的問題而產生的，它所有的字符都用兩個字節表示，即英文字符也是用兩個字節表示。nchar、nvarchar的長度是在1到4000之間。和char、varchar比較：nchar、nvarchar則最多存儲4000個字符，不論是英文還是漢字；而char、varchar最多能存儲8000個英文，4000個漢字。可以看出使用nchar、nvarchar數據類型時不用擔心輸入的字符是英文還是漢字，較為方便，但在存儲英文時數量上有些損失。 </p>
<p>(2)datetime和smalldatetime   <br />datetime：從1753年1月1日到9999年12月31日的日期和時間數據，精確到百分之三秒。    <br />smalldatetime：從1900年1月1日到2079年6月6日的日期和時間數據，精確到分鍾。 </p>
<p>(3)bitint、int、smallint、tinyint和bit   <br />bigint：從-2^63(-9223372036854775808)到2^63-1(9223372036854775807)的整型數據。    <br />int：從-2^31(-2,147,483,648)到2^31-1(2,147,483,647)的整型數據。    <br />smallint：從-2^15(-32,768)到2^15-1(32,767)的整數數據。    <br />tinyint：從0到255的整數數據。    <br />bit：1或0的整數數據。 </p>
<p>(4)decimal和numeric   <br />這兩種數據類型是等效的。都有兩個參數：p（精度）和s（小數位數）。p指定小數點左邊和右邊可以存儲的十進制數字的最大個數，p必須是從 1到38之間的值。s指定小數點右邊可以存儲的十進制數字的最大個數，s必須是從0到p之間的值，默認小數位數是0。 </p>
<p>(5)float和real   <br />float：從-1.79^308到1.79^308之間的浮點數字數據。    <br />real：從-3.40^38到3.40^38之間的浮點數字數據。在SQL Server中，real的同義詞為float(24)。</p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/173/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何將 Excel 資料匯入SQL Server 2005 Express</title>
		<link>http://m955.com/wp/archives/169</link>
		<comments>http://m955.com/wp/archives/169#comments</comments>
		<pubDate>Tue, 25 Nov 2008 00:50:45 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://m955.com/wp/archives/169</guid>
		<description><![CDATA[微軟現在也想搞自由軟體這一套，連續推出了 Express 系列，不過不免詬病一下，既然要免費了為何不開放多一點功能，像 SQL Server 2005 Express 就少了很多功能，不過就整體看起來，還是比 Access ... ]]></description>
			<content:encoded><![CDATA[<p>微軟現在也想搞自由軟體這一套，連續推出了 Express 系列，不過不免詬病一下，既然要免費了為何不開放多一點功能，像 SQL Server 2005 Express 就少了很多功能，不過就整體看起來，還是比 Access 好多了。</p>
<p>SQL Server 2005 Express 有 SQL Server Management Studio Express 來進行圖形化管理，不過卻沒有匯入匯出的功能，有點不方便，但是可以利用其他方法來達成這個匯入功能。</p>
<p>但要使用SQL指令匯入需要先開啟OPENROWSET才能執行匯入功能。
<p>依序操作如下：
<p>Microsoft SQL Server 2005 &gt; 組態工具 &gt; SQL Server 2005 介面組態 &gt; 功能的介面區組態 &gt; 勾選「啟用OPENROWSET和OPENDATASOURCE支援」
<p><a href="http://farm4.static.flickr.com/3249/3056754101_173886c058_o.jpg" target="_blank" rel="lightbox"><img src="http://farm4.static.flickr.com/3249/3056754101_c00c38729c.jpg"></a>
<p>將要匯入的Excel檔就定位，例如放在D:\testdata\zipcode.xls，檢查一下，第一行是欄位名稱，第二行起是資料的部分，然後工作表名稱可以維持原本的Sheet1或是自己重新命名（記得下面的Sheet1$要配合修改） <br />接著就可以執行</p>
<div class="igBar"><span id="lsql-2"><a href="#" onclick="javascript:showPlainTxt('sql-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-2">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">INTO</span> zone <span style="color: #993333; font-weight: bold;">FROM</span> OPENROWSET<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'Microsoft.Jet.OLEDB.4.0'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">'Excel 8.0;Database=D:<span style="color: #000099; font-weight: bold;">\t</span>estdata<span style="color: #000099; font-weight: bold;">\z</span>ipcode.xls'</span>, <span style="color:#006600; font-weight:bold;">&#91;</span>Sheet1$<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/169/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

