Home Incorrect Syntax near '.' (Microsoft SQL Server Native Client 11.0)
Reply: 2

Incorrect Syntax near '.' (Microsoft SQL Server Native Client 11.0)

Sereine Published in 2018-01-10 21:46:29Z
ALTER TABLE [dbo].[CustomerInsuranceNumber]
  ADD CONSTRAINT pk_myConstraint PRIMARY KEY ([dbo].[CustomerStateProvince].[CustomerHQStateProvinceAbbreviation], [CustomerInsuranceNumber])

I am trying to create a composite key made up of a column from the table above and a column from another table. I get an incorrect syntax near '.' for the periods in [dbo].[CustomerStateProvince].[CustomerHQStateProvinceAbbreviation]

How do I fix this error? Thanks.

Nathan Reply to 2018-01-10 21:51:49Z

You cannot create a composite primary key from columns on another table. You need to have that value present on your table. Create a column named [CustomerHQStateProvinceAbbreviation]on your [CustomerInsuranceNumber] table and make the key as this:

ADD CONSTRAINT pk_myConstraint PRIMARY KEY ([CustomerHQStateProvinceAbbreviation], [CustomerInsuranceNumber])
serdroid Reply to 2018-01-10 21:51:59Z

You are trying to add a column from another tablo to primary key. You cannot do this.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.296023 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO