Skip to content

[Bug]: SQL Server States and Cities Create Table Statement has missing Columns: #1350

@ojsanthoshgithib

Description

@ojsanthoshgithib

Issue Type

Incorrect Data (wrong information)

Location (if applicable)

No response

What's wrong?

SQL Server Create Table Statements:

/****** Object: Table [world].[cities] Script Date: 26/02/2026 11:46:11 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [world].[cities](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] nvarchar NOT NULL,
[state_id] [int] NOT NULL,
[state_code] nvarchar NOT NULL,
[state_name] nvarchar NOT NULL,
[country_id] [int] NOT NULL,
[country_code] nchar NOT NULL,
[country_name] nvarchar NOT NULL,
[latitude] [decimal](10, 8) NOT NULL,
[longitude] [decimal](11, 8) NOT NULL,
[native] nvarchar NULL,
[type] nvarchar NULL,
[level] [int] NULL,
[parent_id] [int] NULL,
[population] [bigint] NULL,
[timezone] nvarchar NULL,
[translations] nvarchar NULL,
[wikiDataId] nvarchar NULL,
[created_at] datetime2 NOT NULL,
[updated_at] datetime2 NOT NULL,
[flag] [bit] NOT NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [world].[cities] ADD DEFAULT (sysdatetime()) FOR [created_at]
GO

ALTER TABLE [world].[cities] ADD DEFAULT (sysdatetime()) FOR [updated_at]
GO

ALTER TABLE [world].[cities] ADD DEFAULT ((1)) FOR [flag]
GO

ALTER TABLE [world].[cities] WITH CHECK ADD CONSTRAINT [FK_cities_countries] FOREIGN KEY([country_id])
REFERENCES [world].[countries] ([id])
GO

ALTER TABLE [world].[cities] CHECK CONSTRAINT [FK_cities_countries]
GO

ALTER TABLE [world].[cities] WITH CHECK ADD CONSTRAINT [FK_cities_states] FOREIGN KEY([state_id])
REFERENCES [world].[states] ([id])
GO

ALTER TABLE [world].[cities] CHECK CONSTRAINT [FK_cities_states]
GO

/States Table/

/****** Object: Table [world].[states] Script Date: 26/02/2026 11:47:12 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [world].[states](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] nvarchar NOT NULL,
[country_id] [int] NOT NULL,
[country_code] nchar NOT NULL,
[country_name] nvarchar NOT NULL,
[fips_code] nvarchar NULL,
[iso2] nvarchar NULL,
[iso3166_2] nvarchar NULL,
[type] nvarchar NULL,
[level] [int] NULL,
[parent_id] [int] NULL,
[native] nvarchar NULL,
[latitude] [decimal](10, 8) NULL,
[longitude] [decimal](11, 8) NULL,
[timezone] nvarchar NULL,
[translations] nvarchar NULL,
[wikiDataId] nvarchar NULL,
[population] [bigint] NULL,
[created_at] datetime2 NULL,
[updated_at] datetime2 NOT NULL,
[flag] [bit] NOT NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [world].[states] ADD DEFAULT (sysdatetime()) FOR [created_at]
GO

ALTER TABLE [world].[states] ADD DEFAULT (sysdatetime()) FOR [updated_at]
GO

ALTER TABLE [world].[states] ADD DEFAULT ((1)) FOR [flag]
GO

ALTER TABLE [world].[states] WITH CHECK ADD CONSTRAINT [FK_states_countries] FOREIGN KEY([country_id])
REFERENCES [world].[countries] ([id])
GO

ALTER TABLE [world].[states] CHECK CONSTRAINT [FK_states_countries]
GO

What should it be?

Updated Create Table Statements:

/****** Object: Table [world].[cities] Script Date: 26/02/2026 11:46:11 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [world].[cities](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] nvarchar NOT NULL,
[state_id] [int] NOT NULL,
[state_code] nvarchar NOT NULL,
[state_name] nvarchar NOT NULL,
[country_id] [int] NOT NULL,
[country_code] nchar NOT NULL,
[country_name] nvarchar NOT NULL,
[latitude] [decimal](10, 8) NOT NULL,
[longitude] [decimal](11, 8) NOT NULL,
[native] nvarchar NULL,
[type] nvarchar NULL,
[level] [int] NULL,
[parent_id] [int] NULL,
[population] [bigint] NULL,
[timezone] nvarchar NULL,
[translations] nvarchar NULL,
[wikiDataId] nvarchar NULL,
[created_at] datetime2 NOT NULL,
[updated_at] datetime2 NOT NULL,
[flag] [bit] NOT NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [world].[cities] ADD DEFAULT (sysdatetime()) FOR [created_at]
GO

ALTER TABLE [world].[cities] ADD DEFAULT (sysdatetime()) FOR [updated_at]
GO

ALTER TABLE [world].[cities] ADD DEFAULT ((1)) FOR [flag]
GO

ALTER TABLE [world].[cities] WITH CHECK ADD CONSTRAINT [FK_cities_countries] FOREIGN KEY([country_id])
REFERENCES [world].[countries] ([id])
GO

ALTER TABLE [world].[cities] CHECK CONSTRAINT [FK_cities_countries]
GO

ALTER TABLE [world].[cities] WITH CHECK ADD CONSTRAINT [FK_cities_states] FOREIGN KEY([state_id])
REFERENCES [world].[states] ([id])
GO

ALTER TABLE [world].[cities] CHECK CONSTRAINT [FK_cities_states]
GO

/States Table/

/****** Object: Table [world].[states] Script Date: 26/02/2026 11:47:12 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [world].[states](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] nvarchar NOT NULL,
[country_id] [int] NOT NULL,
[country_code] nchar NOT NULL,
[country_name] nvarchar NOT NULL,
[fips_code] nvarchar NULL,
[iso2] nvarchar NULL,
[iso3166_2] nvarchar NULL,
[type] nvarchar NULL,
[level] [int] NULL,
[parent_id] [int] NULL,
[native] nvarchar NULL,
[latitude] [decimal](10, 8) NULL,
[longitude] [decimal](11, 8) NULL,
[timezone] nvarchar NULL,
[translations] nvarchar NULL,
[wikiDataId] nvarchar NULL,
[population] [bigint] NULL,
[created_at] datetime2 NULL,
[updated_at] datetime2 NOT NULL,
[flag] [bit] NOT NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [world].[states] ADD DEFAULT (sysdatetime()) FOR [created_at]
GO

ALTER TABLE [world].[states] ADD DEFAULT (sysdatetime()) FOR [updated_at]
GO

ALTER TABLE [world].[states] ADD DEFAULT ((1)) FOR [flag]
GO

ALTER TABLE [world].[states] WITH CHECK ADD CONSTRAINT [FK_states_countries] FOREIGN KEY([country_id])
REFERENCES [world].[countries] ([id])
GO

ALTER TABLE [world].[states] CHECK CONSTRAINT [FK_states_countries]
GO

Source (optional)

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions