<?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; ms sql server</title>
	<atom:link href="http://www.cslog.cn/tag/ms-sql-server/feed/zh-hant/" rel="self" type="application/rss+xml" />
	<link>http://www.cslog.cn</link>
	<description>最讓我激動的是不知道下一個星球上能發現什麼...</description>
	<lastBuildDate>Wed, 30 Jul 2025 16:06:05 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>讀取mdf格式的sql server數據文件，並將數據以CSV格式導出</title>
		<link>http://www.cslog.cn/Content/ms-sql-server-mdf-csv/zh-hant/</link>
		<comments>http://www.cslog.cn/Content/ms-sql-server-mdf-csv/zh-hant/#comments</comments>
		<pubDate>Fri, 02 Aug 2013 15:20:35 +0000</pubDate>
		<dc:creator>船長</dc:creator>
				<category><![CDATA[信息處理]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[ms sql server]]></category>
		<category><![CDATA[數據備份]]></category>
		<category><![CDATA[數據庫]]></category>

		<guid isPermaLink="false">http://www.cslog.cn/?p=1182</guid>
		<description><![CDATA[多年以前使用過微軟的SQL Server 2000數據庫。留下一個mdf格式的數 &#8230; <a href="http://www.cslog.cn/Content/ms-sql-server-mdf-csv/zh-hant/">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>多年以前使用過微軟的SQL Server 2000數據庫。留下一個mdf格式的數據文件，臨時用到想把它導出。過程真可以使用災難來形容。現在不用使用微軟的東西來工作了，真是好運啊。</p>
<p>我使用的是MS SQL Express 2005。要在Windows 7上安裝，得安裝SP4版本。安裝後使用它附加上mdf文件。數據庫就可以在上面查詢了。在查詢窗口輸入：<br />
<code><br />
EXEC xp_cmdshell<br />
'BCP "dbname.dbo.tablename" out d:\aa.csv -t , -T -SMY-PC\SQLEXPRESS -w'<br />
</code><br />
這樣的命令，就能將數據導出CSV到文件。其中-t後面的是分隔符，這裡使用的是逗號，注意這樣如果原來數據中也有逗號，會產生數據分隔出問題，這時可以改用其它符號（如####）。-w是指定使用unicode<a href="http://www.cslog.cn/tag/%e6%b1%89%e5%ad%97%e7%bc%96%e7%a0%81/">文字編碼</a>輸出。重點是要加-S參數，指定自己的PC名稱\SQLEXPRESS， 不然會連接出錯，錯誤提示如：</p>
<blockquote><p>
[SQL Native Client]Named Pipes Provider: Could not open a connection<br />
to SQL Server [2].<br />
[SQL Native Client]Login timeout expired<br />
[SQL Native Client]An error has occurred while establishing a<br />
connection to the server. When connecting to SQL Server 2005, this<br />
failure may be caused by the fact that under the default settings SQL<br />
Server does not allow remote connections.
</p></blockquote>
<div style="margin-top: 15px; font-style: italic">
<p>轉載請註明: 轉自<a href="http://www.cslog.cn/">船長日誌</a>, 本文鏈接地址: <a href="http://www.cslog.cn/Content/ms-sql-server-mdf-csv/zh-hant/">http://www.cslog.cn/Content/ms-sql-server-mdf-csv/zh-hant/</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.cslog.cn/Content/ms-sql-server-mdf-csv/feed/zh-hant/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- WP Chinese Conversion Full Page Converted -->