Skip to content

Commit 21c1a0b

Browse files
committed
2 parents 3eef9d3 + 4783718 commit 21c1a0b

File tree

2 files changed

+39
-43
lines changed

2 files changed

+39
-43
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
https://docs.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server
3+
Database objects include objects such as tables, views, stored procedures, user-defined functions, triggers, rules, defaults, and constraints.
4+
The sum of the number of all objects in a database cannot exceed 2,147,483,647.
5+
*/
6+
CREATE DATABASE [TwoMillion];
7+
8+
ALTER DATABASE [TwoMillion] SET RECOVERY SIMPLE WITH NO_WAIT;
9+
GO
10+
11+
USE [TwoMillion];
12+
13+
SET NOCOUNT ON;
14+
15+
DECLARE @sql nvarchar(max) = N'';
16+
DECLARE @i int = 1;
17+
18+
SELECT @i = 2147483647 - COUNT(*) FROM [TwoMillion].sys.objects;
19+
PRINT N'Creating ' + FORMAT(@i,'N0') + N' tables...';
20+
21+
WHILE @i > 0
22+
BEGIN
23+
SET @i -= 1;
24+
25+
SET @sql = N'CREATE TABLE [TwoMillion].dbo.t' + CONVERT(nvarchar(max),2147483648-@i) + N' (i int);';
26+
IF (@i % 10000) = 0 RAISERROR(@sql, 0, 1) WITH NOWAIT;
27+
28+
EXEC sp_executesql @sql;
29+
END;
30+
31+
/*
32+
ALTER DATABASE [TwoMillion] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
33+
GO
34+
35+
USE master;
36+
GO
37+
38+
DROP DATABASE [TwoMillion];
39+
*/

Scripts/Create_2_Millions_Tables.sql

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)