Reputation: 521
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
Upvotes: 0
Views: 77
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