CREATE DATABASE [NullTestDB] ON PRIMARY
( NAME = N'NullTestDB', FILENAME = N'XXXXXXXXXXXXX\NullTestDB.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'NullTestDB_log', FILENAME = N'XXXXXXXXXXXXXXXXXXXXX\NullTestDB_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)
GO
ALTER DATABASE [NullTestDB] SET COMPATIBILITY_LEVEL = 100
GO
ALTER DATABASE [NullTestDB] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [NullTestDB] SET ANSI_NULLS OFF
GO
ALTER DATABASE [NullTestDB] SET ANSI_PADDING OFF
GO
ALTER DATABASE [NullTestDB] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [NullTestDB] SET ARITHABORT OFF
GO
ALTER DATABASE [NullTestDB] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [NullTestDB] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [NullTestDB] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [NullTestDB] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [NullTestDB] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [NullTestDB] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [NullTestDB] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [NullTestDB] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [NullTestDB] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [NullTestDB] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [NullTestDB] SET DISABLE_BROKER
GO
ALTER DATABASE [NullTestDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [NullTestDB] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [NullTestDB] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [NullTestDB] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [NullTestDB] SET READ_WRITE
GO
ALTER DATABASE [NullTestDB] SET RECOVERY FULL
GO
ALTER DATABASE [NullTestDB] SET MULTI_USER
GO
ALTER DATABASE [NullTestDB] SET PAGE_VERIFY CHECKSUM
GO
USE [NullTestDB]
GO
IF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = N'PRIMARY') ALTER DATABASE [NullTestDB] MODIFY FILEGROUP [PRIMARY] DEFAULT
GO
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
CREATE TABLE dbo.Table_1
(
C1 nvarchar(MAX) NULL,
C2 nvarchar(MAX) NULL,
C3 nvarchar(MAX) NULL,
C4 nvarchar(MAX) NULL,
C5 nvarchar(MAX) NULL,
C6 nvarchar(MAX) NULL,
C7 nvarchar(MAX) NULL,
C8 nvarchar(MAX) NULL,
C9 nvarchar(MAX) NULL,
C10 nvarchar(MAX) NULL,
C11 nvarchar(MAX) NULL,
C12 nvarchar(MAX) NULL,
C13 nvarchar(MAX) NULL,
C14 nvarchar(MAX) NULL,
C15 nvarchar(MAX) NULL,
C16 nvarchar(MAX) NULL,
C17 nvarchar(MAX) NULL,
C18 nvarchar(MAX) NULL,
C19 nvarchar(MAX) NULL,
C20 nvarchar(MAX) NULL
) ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE dbo.Table_1 SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
Declare @p_NumberOfRows Bigint
Select @p_NumberOfRows=10000000;
With Base As
(
Select 1 as n
Union All
Select n+1 From Base Where n < Ceiling(SQRT(@p_NumberOfRows))
),
Expand As
(
Select 1 as C From Base as B1, Base as B2
),
Nums As
(
Select Row_Number() OVER(ORDER BY C) As n From Expand
)
INSERT INTO Table_1
Select n, null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null
from Nums Where n<=@p_NumberOfRows
OPTION (MaxRecursion 0);
EXEC sp_spaceused;