I needed to create a temp table in SQL with a column that contained an incrementing integer, without making that column an identity.
Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table.
Often this is the primary key field that we would like to be created automatically every time a new record is inserted.
My SQL uses the AUTO_INCREMENT keyword to perform an auto-increment feature.
By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record.
Products To Insert') AND type in (N'U')) DROP TABLE [dbo].
Products To Insert GO CREATE TABLE Product ( Product ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, [Name] NVARCHAR(50) NOT NULL, Product Number NVARCHAR(25) NOT NULL, List Price MONEY NOT NULL) GO CREATE UNIQUE INDEX IX_Product_Product Number ON Product ( Product Number ) GO CREATE TABLE Products To Insert ( Row ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, [Name] NVARCHAR(50) NOT NULL, Product Number NVARCHAR(25) NOT NULL, List Price MONEY NOT NULL, Inserted Identity Value INT NULL) GO INSERT Product ([Name], Product Number, List Price) SELECT TOP 450 [Name], Product Number, List Price FROM Adventure Works. Product ORDER BY Sell Start Date, Product ID GO INSERT Products To Insert ([Name], Product Number, List Price) SELECT [Name], Product Number, List Price FROM Adventure Works. Product GO The Product table has an identity column as its primary key. The Products To Insert table has the Product Number column and a column for whatever identity value is inserted when we put the row into the Product table.
Please consider to redesign your database architecture so, it should have only single primary unique key marked as an identity column.
If it is impossible for you to change the database schema, you will have to move the "key" attribute from the IDEvento Registrato to the Progressivo property: Hi Stan, this is so surprising to me. Identity is set at DB level - nothing is required to XPO so you mean than there are no way to have a readonly property that is only "get" from db and never "set" ?????? Hi Carlo, XPO supports read only properties, but these properties can't be persistent.
The scenario is a vendor that sends you a complete list of all their products and you only need to insert the rows that don't already exist.