Question

Failed to write to Azure SQL table

  • 8 October 2019
  • 6 replies
  • 15 views

Badge +2

Hi.

I'm trying to write some data into a table which consists of two foreign keys. As you can see on the attached image, I'm reading from two tables, Equipment and WaterMeterPnt. Equipment contains a field BuildingId which I'm going to add to the table WaterMeterPntBuilding. I'm joining the two tables on an common field. The table WaterMeterPntBuilding contains just two fields which is foreign keys.

When I try to run this, I get this error when writing:

Microsoft SQL Server Non-Spatial Writer: Failed to create Azure table 'dbo.WaterMeterPntBuilding' because no clustered index or primary key was specified.

I'm sure that the values exists in the tables and I'm using the existing table, not creating the table each time.

 

Regards,

Torbjørn

 


6 replies

Badge +21

Hi Torbjørn! If you double click on the writer Feature and user attribues. Does it say Definition: Automatic - manual or dynamic? Can you post a screenshot of both Parameters and User Attributes

Badge +2

Here are the details, @sigtill . For the attribute definition I'm using manual since the table is imported directly from the writer

As for the parameters, I'm inserting values and trying to use the existing table:

 

Torbjørn

Badge +21

Here are the details, @sigtill . For the attribute definition I'm using manual since the table is imported directly from the writer

As for the parameters, I'm inserting values and trying to use the existing table:

 

Torbjørn

What if you switch to Attribute handling: Automatic ?

Badge +2

What if you switch to Attribute handling: Automatic ?

I get the same error:

Microsoft SQL Server Non-Spatial Writer: Failed to create Azure table 'dbo.WaterMeterPntBuilding' because no clustered index or primary key was specified. If creating a new table, go into the 'User Attribute' tab and set the 'Index' column to 'clustered', 'clustered_not_null', or 'primary_key' for a column

Badge +21

I get the same error:

Microsoft SQL Server Non-Spatial Writer: Failed to create Azure table 'dbo.WaterMeterPntBuilding' because no clustered index or primary key was specified. If creating a new table, go into the 'User Attribute' tab and set the 'Index' column to 'clustered', 'clustered_not_null', or 'primary_key' for a column

So go to manual and change Index column to clustered to see if that works - even though you are not creating a new table.

Certain Sql Server Azure database versions REQUIRE either a Primary Key on a table or a Clustered Index. If your table(s) do not have either, then you need to create a clustered index on the table.

 

Sql Code:

 

CREATE CLUSTERED INDEX IX_TableName_colName

ON [dbo].[TableName] (colName);

GO

Reply