U.S States MSSQL

Prefabricated/Populated database quires. Prefabricated/populated database tables to help you out. These quires are ready to go. Just simply execute and watch your data populate.
Post Reply
dzcadii
Posts: 94
Joined: Sun Mar 01, 2015 4:36 am

U.S States MSSQL

Post by dzcadii » Sun Mar 01, 2015 6:10 pm

Code: Select all

/****** Object:  Table [dbo].[tbl_States]    Script Date: 07/26/2013 12:02:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbl_States]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tbl_States](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[State] [varchar](150) NOT NULL,
	[IsState] [char](1) NOT NULL,
 CONSTRAINT [PK_tbl_States] PRIMARY KEY CLUSTERED 
(
	[State] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[tbl_States] ON
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (1, N'Alabama', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (2, N'Alaska', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (55, N'APO', N'0')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (3, N'Arizona', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (4, N'Arkansas', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (5, N'California', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (6, N'Colorado', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (7, N'Connecticut', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (8, N'Delaware', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (9, N'Florida', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (10, N'Georgia', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (11, N'Hawaii', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (12, N'Idaho', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (13, N'Illinois', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (14, N'Indiana', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (15, N'Iowa', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (16, N'Kansas', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (17, N'Kentucky', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (18, N'Louisiana', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (19, N'Maine', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (20, N'Maryland', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (21, N'Massachusetts', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (22, N'Michigan', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (23, N'Minnesota', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (24, N'Mississippi', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (25, N'Missouri', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (26, N'Montana', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (27, N'Nebraska', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (28, N'Nevada', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (29, N'New Hampshire', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (30, N'New Jersey', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (31, N'New Mexico', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (32, N'New York', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (33, N'North Carolina', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (34, N'North Dakota', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (35, N'Northern Marianas Islands', N'0')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (36, N'Ohio', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (37, N'Oklahoma', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (38, N'Oregon', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (39, N'Pennsylvania', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (54, N'Puerto Rico', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (40, N'Rhode Island', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (41, N'South Carolina', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (42, N'South Dakota', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (43, N'Tennessee', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (44, N'Texas', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (45, N'Utah', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (46, N'Vermont', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (48, N'Virgin Islands', N'0')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (47, N'Virginia', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (49, N'Washington DC', N'0')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (50, N'Washington State', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (51, N'West Virginia', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (52, N'Wisconsin', N'1')
INSERT [dbo].[tbl_States] ([id], [State], [IsState]) VALUES (53, N'Wyoming', N'1')
SET IDENTITY_INSERT [dbo].[tbl_States] OFF

GO
/****** Object:  Default [DF_tbl_States_IsState]    Script Date: 07/26/2013 12:02:33 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tbl_States_IsState]') AND parent_object_id = OBJECT_ID(N'[dbo].[tbl_States]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tbl_States_IsState]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tbl_States] ADD  CONSTRAINT [DF_tbl_States_IsState]  DEFAULT ((1)) FOR [IsState]
END

Post Reply