USE [OrderDB] GO /****** Object: StoredProcedure [dbo].[CreateTestData] Script Date: 2/2/2023 2:46:33 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTERPROCEDURE [dbo].[CreateTestData] @Numberint AS BEGIN DECLARE @Counterint=1 WHILE @Counter<=@Number BEGIN INSERTINTO Orders (OrderDate,OrderNumber,IsValid,CreatedOn,UpdatedOn) VALUES ( DATEADD(DAY, ABS(CHECKSUM(NEWID()) %3650), '2000-01-01'), CONVERT(CHAR(8), FORMAT(GetDate(),'yyyyMMdd')) +right('00000000'+cast(@Counterasvarchar(8)),8), 1, GETDATE(), GETDATE() ) SET@Counter=@Counter+1 END END
The stored procedure inserts a random date into OrderDate and a sequence number into OrderNumber.