use ITVisionsCRM
--CREATE TABLE Kunde (ID INT, Kundenname NVARCHAR(50), Datum DATETIME2)
 SET NOCOUNT ON
-- print "Truncating table..."
--truncate table kunde

DECLARE @RowCount INT
DECLARE @RowString VARCHAR(10)
DECLARE @Random INT
DECLARE @Upper INT
DECLARE @Lower INT
DECLARE @InsertDate DATETIME

SET @Lower = -730
SET @Upper = -1
SET @RowCount = 1000
delete from kunde where ID >= @rowcount

WHILE @RowCount <= 11000
BEGIN
	SET @RowString = CAST(@RowCount AS VARCHAR(10))
	SELECT @Random = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
	SET @InsertDate = DATEADD(dd, @Random, GETDATE())
	if @rowcount % 100 = 0 
            print @RowCount
	INSERT INTO Kunde
		(ID
		,Kundenname
		,Datum)
	VALUES
		(@RowCount,concat('Test',@RowCount),DATEADD(dd, @RowCount, @InsertDate))
	
	SET @RowCount = @RowCount + 1
END