Eksportuj (0) Drukuj
Rozwiń wszystko
EN
Ta zawartość nie jest dostępna w wymaganym języku. Wersja w języku angielskim znajduje się tutaj.
48 z 86 osób oceniło jako pomocne - Oceń ten temat

How to: Connect to Windows Azure SQL Database Using sqlcmd

You can connect to Microsoft Windows Azure SQL Database with the sqlcmd command prompt utility that is included with SQL Server. The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt. 

For general considerations about connecting to databases in SQL Database, see Guidelines for Connecting to Windows Azure SQL Database.

Connecting with sqlcmd

To connect to Windows Azure SQL Database by using sqlcmd, append the SQL Database server name to the login in the connection string by using the <login>@<server> notation. For example, if your login is login1 and the fully qualified name of the SQL Database server is servername.database.windows.net, the username parameter of the connection string is: login1@servername. This restriction places limitations on the text you can choose for the login name. For more information, see CREATE LOGIN (Windows Azure SQL Database).

noteNote
Windows Azure SQL Database does not support the –z and –Z options used for changing users password with SQLCMD. To change login passwords, you can use the ALTER LOGIN (Windows Azure SQL Database) after connecting to the master database.

The following example shows how to connect to the master database in an SQL Database server and then creates a sample database by using the Transact-SQL CREATE DATABASE (Windows Azure SQL Database) statement:

C:\>sqlcmd -U <ProvideLogin@Server> -P <ProvidePassword> -S <ProvideServerName> -d master
1> CREATE DATABASE <ProvideDatabaseName>;
2> GO
1> QUIT

Next, you can connect to the previously created database directly and create a new table in the database by using the Transact-SQL CREATE TABLE (Windows Azure SQL Database) statement:

C:\>sqlcmd -U <ProvideLogin@Server> -P <ProvidePassword> -S <ProvideServerName> -d <ProvideDatabaseName>
1> CREATE TABLE table1 (Col1 int primary key, Col2 varchar(20));
2> GO
3> QUIT
noteNote
Windows Azure SQL Database does not support heap tables. You must create a primary key or a clustered index. For more information, see General Guidelines and Limitations (Windows Azure SQL Database).

For more information about the sqlcmd Utility, see sqlcmd Utility in SQL Server Books Online.

See Also

Czy oceniasz te materiały jako pomocne?
(Pozostało znaków: 1500)
Dziękujemy za opinię.

Zawartość społeczności

Dodaj
Pokaż:
© 2014 Microsoft. Wszelkie prawa zastrzeżone.