Skip to content
December 22, 2010 / windperson

SQL Server Management Studio(SSMS)查詢產生.csv檔

用SQL Server Management Studio(SSMS)對SQL Server下SQL查詢,碰到有些需要產生可以在Excel呈現的狀況,可以用將query結果產生.csv檔的方式,然後再用excel開啟:

  1. 設定SSMS的Query Result→在SSMS的[Tools]\[Options]裡面的選項,設定Result to Text的Output format為”Comma delimited"
    image
  2. 在SSMS主視窗,創建新的SQL查詢分頁時,選擇上方SQL Editor工具列有個Results to File按鈕(遠本預設是選在中間的Results to Grid):
    image
  3. 按F5或執行按鈕(image)執行SQL查詢,此時跳出的儲存檔案對話視窗,選擇儲存檔案類型為All Files(*.*),然後在檔名的文字方塊上鍵入自行指定的檔名+".csv"結尾即可。
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: