Ssms 公用程式

Ssms 公用程式會開啟 SQL Server Management Studio。如果有指定,Ssms 也會建立伺服器的連接,且會開啟查詢、指令碼、檔案、專案和方案。

您可以指定包含查詢、專案或方案的檔案。如果提供了連接資訊,且檔案類型與這個類型的伺服器相關聯,包含查詢的檔案會自動連接伺服器。例如,.sql 檔會在 SQL Server Management Studio 中開啟一個 [SQL 查詢編輯器] 視窗,.mdx 檔會在 SQL Server Management Studio 中開啟一個 [MDX 查詢編輯器] 視窗。而 SQL Server 方案和專案會在 SQL Server Management Studio 中開啟。

[!附註]

Ssms 公用程式不會執行查詢。若要從命令列中執行查詢,請使用 sqlcmd 公用程式。

語法

Ssms
    [scriptfile] [projectfile] [solutionfile]
    [-S servername] [-d databasename] [-U username] [-P password] 
    [-E] [-nosplash] [-?]

引數

  • scriptfile
    指定一或多個要開啟的指令碼檔案。這個參數必須包含檔案的完整路徑。

  • projectfile
    指定要開啟的指令碼專案。這個參數必須包含指令碼專案檔的完整路徑。

  • solutionfile
    指定要開啟的方案。這個參數必須包含方案檔的完整路徑。

  • [[-Sservername]
    伺服器名稱

  • [[-ddatabasename]
    資料庫名稱。

  • [[-U username]
    利用 SQL Server 驗證來連接時的使用者名稱

  • [[-Ppassword]
    利用 SQL Server 驗證來連接時的密碼

  • [[-E]
    使用 Windows 驗證來連接

  • -nosplash
    在開啟時,使 SQL Server Management Studio 不呈現開頭顯示畫面。當您利用頻寬有限的連接,透過「終端機服務」來連接執行 SQL Server Management Studio 的電腦時,請使用這個選項。這個引數不區分大小寫,可出現在其他引數的前後。

  • [-?]
    顯示命令列說明

備註

所有參數都是選擇性的,除了用逗號來分隔的檔案之外,您必須用空格來分隔它們。如果您沒有指定任何參數,Ssms 會依照 [工具] 功能表 [選項] 設定中所指定的內容來開啟 SQL Server Management Studio。例如,如果 [環境/一般] 頁面的 [啟動時] 選項指定 [開啟新增查詢視窗]Ssms 會以空白的查詢編輯器開啟。

如果提供了連接資訊,且檔案類型與這個類型的伺服器相關聯,便會發出包含查詢的檔案連接到伺服器的提示。例如,.sql 檔會在 SQL Server Management Studio 中開啟一個 [SQL 查詢編輯器] 視窗,.mdx 檔會在 SQL Server Management Studio 中開啟一個 [MDX 查詢編輯器] 視窗。而 SQL Server 方案和專案會在 SQL Server Management Studio 中開啟。

下表將伺服器類型對應至副檔名。

伺服器類型

副檔名

SQL Server

.sql

SQL Server Compact 3.5 SP1

.sqlce

SQL Server Analysis Services

.mdx

.xmla

範例

下列指令碼會在命令提示字元之下,利用預設值來開啟 SQL Server Management Studio:

sqlwb

下列指令碼會在命令提示字元之下,將程式碼編輯器設為伺服器 ACCTG and the database AdventureWorks,,在不呈現開頭顯示畫面的情況下,利用 Windows 驗證來開啟 SQL Server Management Studio:

Ssms -E -S ACCTG -d AdventureWorks -nosplash

下列指令碼會在命令提示字元之下開啟 SQL Server Management Studio,且會開啟 MonthEndQuery 指令碼。

Ssms "C:\Documents and Settings\username\My Documents\SQL Server Management Studio Projects\FinanceScripts\FinanceScripts\MonthEndQuery.sql"

下列指令碼會在命令提示字元之下開啟 SQL Server Management Studio,且會在名稱為 developer 的電腦上開啟 NewReportsProject 專案:

Ssms "\\developer\fin\ReportProj\ReportProj\NewReportProj.ssmssqlproj"

下列指令碼會在命令提示字元之下開啟 SQL Server Management Studio,且會開啟 MonthlyReports 方案:

Ssms "C:\solutionsfolder\ReportProj\MonthlyReports.ssmssln"

請參閱

其他資源