Skip to main content
Question

Failed to write to Azure SQL table


torbjornd
Contributor
Forum|alt.badge.img+4

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

sigtill
Contributor
Forum|alt.badge.img+24
  • Contributor
  • October 9, 2019

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


torbjornd
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • October 15, 2019

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


sigtill
Contributor
Forum|alt.badge.img+24
  • Contributor
  • October 15, 2019
torbjornd wrote:

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 ?


torbjornd
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • October 15, 2019
sigtill wrote:

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


sigtill
Contributor
Forum|alt.badge.img+24
  • Contributor
  • October 15, 2019
torbjornd wrote:

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.


david.benoit

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings