SMR
SMR

Reputation: 521

Include companyID for each customer and link it to other tables SQL

We have client data in our database that comes with ID(OrangeCustID), I am trying to autogenerate myCompanyID to each customer apart from the OrangeCustID and link it to the other tables and have it for our internal queries from SQL Server database.

Could someone please suggest how to achieve this?

Below is the sample table

enter image description here

Upvotes: 0

Views: 77

Answers (1)

Andreas Sundström
Andreas Sundström

Reputation: 218

Just use a primary Key with identity column. When you insert the external data to the table SQL will generate the InternalId automatically.

CREATE TABLE dbo.MyTableName (
  InternalId INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
  OrangeCustID INT NOT NULL,
  Name NVARCHAR(250),
  Gender NVARCHAR(1),
  Order NVARCHAR(250),
  Cost INT
)

Upvotes: 2

Related Questions