2017-05-09 140 views
-1

我是SQL Server中的新成員,有人可以幫助我從SQL Server中的命令行工具執行SQL查詢嗎?如何從SQL Server的命令行工具執行sql查詢?

+4

的可能的複製[如何執行在命令提示(CMD)SQL語句](http://stackoverflow.com/questions/20965846/how-to-execute-sql-statements-in-command-prompt -cmd) –

回答

0

使用以下命令提示符查詢以使用SQLCMD執行filename.sql。

SQLCMD -d <database-name> -U <User-name> -P <Password> -i filename.sql -o output.txt 

-d = Database Name 
-U = User Name 
-P = Password 
-i = Filename.sql 
-o = output.txt 
-E = Windows Authentication mode if you specify this need to skip -U & -P parameters.