简体   繁体   中英

Create table using sqlcmd || Azure SQL Server

I have a create table statement in a file. Using sqlcmd command, I want to create a table. Below is the table structure present in the file column.sql :

CREATE TABLE [dbname].[accessforms].tblename1 
(
     pk_column int PRIMARY KEY, 
     column_1 int NOT NULL
);
GO

I run it like this:

sqlcmd -S server_name -U username -P password -i /home/usr/columns.sql -o /home/usr/columns.txt

And I am getting this error;

Reference to database and/or server name in 'dbname.accessforms.tblename1' is not supported in this version of SQL Server

Could you please help me? Why am I getting this error and how we can solve this?

You're running that query in the Cloud.

Azure Cloud doesn't allow three part naming conventions, such as database_name.schema_name.object_name. You'll have to drop the database name from your reference and only use schema.object.

Your script will have to become:

    CREATE TABLE [accessforms].tblename1 
(
     pk_column int PRIMARY KEY, 
     column_1 int NOT NULL
);
GO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM