Question of the Day
In SQL Server 2022, I run this code:
CREATE SEQUENCE myseqtest START WITH 1 INCREMENT BY 1;
GO
CREATE TABLE NewMonthSales
(SaleID INT
, SecondID int
, saleyear INT
, salemonth TINYINT
, currSales NUMERIC(10, 2));
GO
INSERT dbo.NewMonthSales
(SaleID, SecondID, saleyear, salemonth, currSales)
SELECT
NEXT VALUE FOR myseqtest
, NEXT VALUE FOR myseqtest
, ms.saleyear
, ms.salemonth
, ms.currMonthSales
FROM dbo.MonthSales AS ms;
GO
SELECT * FROM dbo.NewMonthSales AS nms
Assume the dbo.MonthSales table exists. If I run this, what happens?
See possible answers