2016-07-24 69 views
13

現在SQL Serverを学習中ですが、sqlcmdを使用してローカルデータベースへの接続に問題があります。sqlcmd経由でLocalDBに接続できません

私はPowerShellのに次のように入力すると:

sqlcmd -S "(localdb)\mssqllocaldb" 

私は、次のエラーメッセージが表示されます。

Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : SQL Server Network Interfaces: The system cannot find the file specified.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

私はSQL Server Management Studioを使用している場合、私はローカルデータベースに接続することができます。インスタンス名パイプを使用すると、ローカルデータベースに接続することもできます。

私はクリーンなWindows 10のx64、Visual Studioのコミュニティ、およびSQL Server Management Studioの2016年

+0

は '(localdb)'あなたのホスト名で、 'データベース・インスタンスの名前をmssqllocaldb'? TCPプロトコルを有効にしましたか(https://technet.microsoft.com/en-us/library/hh231672%28v=sql.110%29.aspx)? [参考](https://msdn.microsoft.com/de-ch/library/ms188247.aspx) –

+0

'Invoke-Sqlcmd'を使用すると、この問題が解決しました。ここの答えの提案:http://stackoverflow.com/questions/34457048/trouble-connecting-to-localdb-via-sqlcmd-in-powershell-what-is-server-instance –

+0

同じ問題がある無回答 –

答えて

1

のインストール

sqlcmd -S ".\mssqllocaldb" 

または

sqlcmd -S ".\mssqllocaldb -uYOUR_User -pYOUR_PASSWORD" 
+0

また、サービスが開始されていることを確認してください –

7

を試してきたdriver bugがでしたODBCドライブ13. ODBCドライバのインストール13.1アップデートでこれが解決されます。

download the driver hereです。

その後は、CMDまたはPowerShellで使用することができるはずです。

sqlcmd -S "(localdb)\MSSQLLocalDB" -i C:\path\to\file.sql 
関連する問題