Skip to content

Commit

Permalink
*.sql text working-tree-encoding=UTF-16 eol=CRLF
Browse files Browse the repository at this point in the history
  • Loading branch information
dbqopdb committed Nov 22, 2019
1 parent d7c4bc9 commit 7a0c7f6
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
*.sql diff merge text
*.strings diff=utf16
# *.sql text working-tree-encoding=UTF-16 eol=CRLF
*.sql text working-tree-encoding=UTF-16LE eol=CRLF
*.sql text working-tree-encoding=UTF-16 eol=CRLF
Binary file modified .vs/slnx.sqlite
Binary file not shown.
135 changes: 71 additions & 64 deletions DataBase.All.Objects.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
USE [master]
GO
/****** Object: Database [MonthlyPartitionsTest] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: Database [MonthlyPartitionsTest] Script Date: 11/22/2019 1:49:40 PM ******/
CREATE DATABASE [MonthlyPartitionsTest]
CONTAINMENT = NONE
ON PRIMARY
Expand Down Expand Up @@ -153,13 +153,13 @@ ALTER DATABASE [MonthlyPartitionsTest] SET QUERY_STORE = OFF
GO
USE [MonthlyPartitionsTest]
GO
/****** Object: PartitionFunction [UPF_Test_Monthly] Script Date: 11/20/2019 12:32:14 PM ******/
CREATE PARTITION FUNCTION [UPF_Test_Monthly](date) AS RANGE RIGHT FOR VALUES (N'2025-09-01T00:00:00.000', N'2025-10-01T00:00:00.000', N'2025-11-01T00:00:00.000', N'2025-12-01T00:00:00.000', N'2026-01-01T00:00:00.000', N'2026-02-01T00:00:00.000', N'2026-03-01T00:00:00.000', N'2026-04-01T00:00:00.000', N'2026-05-01T00:00:00.000', N'2026-06-01T00:00:00.000', N'2026-07-01T00:00:00.000', N'2026-08-01T00:00:00.000', N'2026-09-01T00:00:00.000', N'2026-10-01T00:00:00.000', N'2026-11-01T00:00:00.000', N'2026-12-01T00:00:00.000', N'2027-01-01T00:00:00.000', N'2027-02-01T00:00:00.000', N'2027-03-01T00:00:00.000', N'2027-04-01T00:00:00.000', N'2027-05-01T00:00:00.000', N'2027-06-01T00:00:00.000', N'2027-07-01T00:00:00.000', N'2027-08-01T00:00:00.000', N'2027-09-01T00:00:00.000', N'2027-10-01T00:00:00.000', N'2027-11-01T00:00:00.000', N'2027-12-01T00:00:00.000', N'2028-01-01T00:00:00.000', N'2028-02-01T00:00:00.000', N'2028-03-01T00:00:00.000', N'2028-04-01T00:00:00.000', N'2028-05-01T00:00:00.000', N'2028-06-01T00:00:00.000', N'2028-07-01T00:00:00.000', N'2028-08-01T00:00:00.000')
/****** Object: PartitionFunction [UPF_Test_Monthly] Script Date: 11/22/2019 1:49:40 PM ******/
CREATE PARTITION FUNCTION [UPF_Test_Monthly](date) AS RANGE RIGHT FOR VALUES (N'2028-07-01T00:00:00.000', N'2028-08-01T00:00:00.000', N'2028-09-01T00:00:00.000', N'2028-10-01T00:00:00.000', N'2028-11-01T00:00:00.000', N'2028-12-01T00:00:00.000', N'2029-01-01T00:00:00.000', N'2029-02-01T00:00:00.000', N'2029-03-01T00:00:00.000', N'2029-04-01T00:00:00.000', N'2029-05-01T00:00:00.000', N'2029-06-01T00:00:00.000', N'2029-07-01T00:00:00.000', N'2029-08-01T00:00:00.000', N'2029-09-01T00:00:00.000', N'2029-10-01T00:00:00.000', N'2029-11-01T00:00:00.000', N'2029-12-01T00:00:00.000', N'2030-01-01T00:00:00.000', N'2030-02-01T00:00:00.000', N'2030-03-01T00:00:00.000', N'2030-04-01T00:00:00.000', N'2030-05-01T00:00:00.000', N'2030-06-01T00:00:00.000', N'2030-07-01T00:00:00.000', N'2030-08-01T00:00:00.000', N'2030-09-01T00:00:00.000', N'2030-10-01T00:00:00.000', N'2030-11-01T00:00:00.000', N'2030-12-01T00:00:00.000', N'2031-01-01T00:00:00.000', N'2031-02-01T00:00:00.000', N'2031-03-01T00:00:00.000', N'2031-04-01T00:00:00.000', N'2031-05-01T00:00:00.000', N'2031-06-01T00:00:00.000')
GO
/****** Object: PartitionScheme [UPS_Test_Monthly] Script Date: 11/20/2019 12:32:14 PM ******/
CREATE PARTITION SCHEME [UPS_Test_Monthly] AS PARTITION [UPF_Test_Monthly] TO ([FG_Test_Monthly_Y00M00], [FG_Test_Monthly_Y01M09], [FG_Test_Monthly_Y01M10], [FG_Test_Monthly_Y01M11], [FG_Test_Monthly_Y01M12], [FG_Test_Monthly_Y02M01], [FG_Test_Monthly_Y02M02], [FG_Test_Monthly_Y02M03], [FG_Test_Monthly_Y02M04], [FG_Test_Monthly_Y02M05], [FG_Test_Monthly_Y02M06], [FG_Test_Monthly_Y02M07], [FG_Test_Monthly_Y02M08], [FG_Test_Monthly_Y02M09], [FG_Test_Monthly_Y02M10], [FG_Test_Monthly_Y02M11], [FG_Test_Monthly_Y02M12], [FG_Test_Monthly_Y03M01], [FG_Test_Monthly_Y03M02], [FG_Test_Monthly_Y03M03], [FG_Test_Monthly_Y03M04], [FG_Test_Monthly_Y03M05], [FG_Test_Monthly_Y03M06], [FG_Test_Monthly_Y03M07], [FG_Test_Monthly_Y03M08], [FG_Test_Monthly_Y03M09], [FG_Test_Monthly_Y03M10], [FG_Test_Monthly_Y03M11], [FG_Test_Monthly_Y03M12], [FG_Test_Monthly_Y01M01], [FG_Test_Monthly_Y01M02], [FG_Test_Monthly_Y01M03], [FG_Test_Monthly_Y01M04], [FG_Test_Monthly_Y01M05], [FG_Test_Monthly_Y01M06], [FG_Test_Monthly_Y01M07], [FG_Test_Monthly_Y01M08])
/****** Object: PartitionScheme [UPS_Test_Monthly] Script Date: 11/22/2019 1:49:40 PM ******/
CREATE PARTITION SCHEME [UPS_Test_Monthly] AS PARTITION [UPF_Test_Monthly] TO ([FG_Test_Monthly_Y00M00], [FG_Test_Monthly_Y01M07], [FG_Test_Monthly_Y01M08], [FG_Test_Monthly_Y01M09], [FG_Test_Monthly_Y01M10], [FG_Test_Monthly_Y01M11], [FG_Test_Monthly_Y01M12], [FG_Test_Monthly_Y02M01], [FG_Test_Monthly_Y02M02], [FG_Test_Monthly_Y02M03], [FG_Test_Monthly_Y02M04], [FG_Test_Monthly_Y02M05], [FG_Test_Monthly_Y02M06], [FG_Test_Monthly_Y02M07], [FG_Test_Monthly_Y02M08], [FG_Test_Monthly_Y02M09], [FG_Test_Monthly_Y02M10], [FG_Test_Monthly_Y02M11], [FG_Test_Monthly_Y02M12], [FG_Test_Monthly_Y03M01], [FG_Test_Monthly_Y03M02], [FG_Test_Monthly_Y03M03], [FG_Test_Monthly_Y03M04], [FG_Test_Monthly_Y03M05], [FG_Test_Monthly_Y03M06], [FG_Test_Monthly_Y03M07], [FG_Test_Monthly_Y03M08], [FG_Test_Monthly_Y03M09], [FG_Test_Monthly_Y03M10], [FG_Test_Monthly_Y03M11], [FG_Test_Monthly_Y03M12], [FG_Test_Monthly_Y01M01], [FG_Test_Monthly_Y01M02], [FG_Test_Monthly_Y01M03], [FG_Test_Monthly_Y01M04], [FG_Test_Monthly_Y01M05], [FG_Test_Monthly_Y01M06])
GO
/****** Object: UserDefinedFunction [dbo].[SVF_GetMonthlyExclusivePartitionNo] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: UserDefinedFunction [dbo].[SVF_GetMonthlyExclusivePartitionNo] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down Expand Up @@ -282,7 +282,7 @@ BEGIN
return @
END
GO
/****** Object: UserDefinedFunction [dbo].[SVF_GetMonthlyPartitionNo] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: UserDefinedFunction [dbo].[SVF_GetMonthlyPartitionNo] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down Expand Up @@ -381,7 +381,7 @@ BEGIN

END
GO
/****** Object: UserDefinedFunction [dbo].[iTVF_TablesPartitionsInfo] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: UserDefinedFunction [dbo].[iTVF_TablesPartitionsInfo] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down Expand Up @@ -717,7 +717,7 @@ where
)
)
GO
/****** Object: UserDefinedFunction [dbo].[iTVF_TablesPartitionsStorageInfo] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: UserDefinedFunction [dbo].[iTVF_TablesPartitionsStorageInfo] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down Expand Up @@ -913,7 +913,7 @@ from

)
GO
/****** Object: Table [dbo].[Test_Monthly] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: Table [dbo].[Test_Monthly] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand All @@ -922,19 +922,19 @@ CREATE TABLE [dbo].[Test_Monthly](
[DataDate] [date] NULL
) ON [UPS_Test_Monthly]([DataDate])
GO
/****** Object: Index [c_a_Dd] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: Index [c_a_Dd] Script Date: 11/22/2019 1:49:40 PM ******/
CREATE CLUSTERED INDEX [c_a_Dd] ON [dbo].[Test_Monthly]
(
[DataDate] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [UPS_Test_Monthly]([DataDate])
GO
/****** Object: Index [nc_a_Dd] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: Index [nc_a_Dd] Script Date: 11/22/2019 1:49:40 PM ******/
CREATE NONCLUSTERED INDEX [nc_a_Dd] ON [dbo].[Test_Monthly]
(
[DataDate] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [UPS_Test_Monthly]([DataDate])
GO
/****** Object: StoredProcedure [dbo].[zsp_CreateSampleTable] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: StoredProcedure [dbo].[zsp_CreateSampleTable] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand All @@ -949,15 +949,17 @@ end

IF EXISTS (SELECT * FROM sys.partition_schemes WHERE name = N'UPS_Test_Monthly')
begin
drop PARTITION SCHEME UPS_Test_Monthly
drop PARTITION
SCHEME UPS_Test_Monthly
end

IF EXISTS (SELECT * FROM sys.partition_functions WHERE name = N'UPF_Test_Monthly')
begin
drop PARTITION FUNCTION [UPF_Test_Monthly]
drop PARTITION FUNCTION
[UPF_Test_Monthly]
end

CREATE PARTITION FUNCTION [UPF_Test_Monthly] (date)
CREATE PARTITION FUNCTION [UPF_Test_Monthly](date)
AS RANGE right FOR VALUES --[x,y)
(
'2019-01-01'
Expand All @@ -972,6 +974,7 @@ AS RANGE right FOR VALUES --[x,y)
, '2019-10-01'
, '2019-11-01'
, '2019-12-01'

, '2020-01-01'
, '2020-02-01'
, '2020-03-01'
Expand All @@ -984,6 +987,7 @@ AS RANGE right FOR VALUES --[x,y)
, '2020-10-01'
, '2020-11-01'
, '2020-12-01'

, '2021-01-01'
, '2021-02-01'
, '2021-03-01'
Expand All @@ -1003,50 +1007,54 @@ CREATE PARTITION SCHEME UPS_Test_Monthly
AS PARTITION [UPF_Test_Monthly]
TO
(
[FG_Test_Monthly_Y00M00]
,[FG_Test_Monthly_Y01M01]
,[FG_Test_Monthly_Y01M02]
,[FG_Test_Monthly_Y01M03]
,[FG_Test_Monthly_Y01M04]
,[FG_Test_Monthly_Y01M05]
,[FG_Test_Monthly_Y01M06]
,[FG_Test_Monthly_Y01M07]
,[FG_Test_Monthly_Y01M08]
,[FG_Test_Monthly_Y01M09]
,[FG_Test_Monthly_Y01M10]
,[FG_Test_Monthly_Y01M11]
,[FG_Test_Monthly_Y01M12]
,[FG_Test_Monthly_Y02M01]
,[FG_Test_Monthly_Y02M02]
,[FG_Test_Monthly_Y02M03]
,[FG_Test_Monthly_Y02M04]
,[FG_Test_Monthly_Y02M05]
,[FG_Test_Monthly_Y02M06]
,[FG_Test_Monthly_Y02M07]
,[FG_Test_Monthly_Y02M08]
,[FG_Test_Monthly_Y02M09]
,[FG_Test_Monthly_Y02M10]
,[FG_Test_Monthly_Y02M11]
,[FG_Test_Monthly_Y02M12]
,[FG_Test_Monthly_Y03M01]
,[FG_Test_Monthly_Y03M02]
,[FG_Test_Monthly_Y03M03]
,[FG_Test_Monthly_Y03M04]
,[FG_Test_Monthly_Y03M05]
,[FG_Test_Monthly_Y03M06]
,[FG_Test_Monthly_Y03M07]
,[FG_Test_Monthly_Y03M08]
,[FG_Test_Monthly_Y03M09]
,[FG_Test_Monthly_Y03M10]
,[FG_Test_Monthly_Y03M11]
,[FG_Test_Monthly_Y03M12]
[FG_Test_Monthly_Y00M00]

, [FG_Test_Monthly_Y01M01]
, [FG_Test_Monthly_Y01M02]
, [FG_Test_Monthly_Y01M03]
, [FG_Test_Monthly_Y01M04]
, [FG_Test_Monthly_Y01M05]
, [FG_Test_Monthly_Y01M06]
, [FG_Test_Monthly_Y01M07]
, [FG_Test_Monthly_Y01M08]
, [FG_Test_Monthly_Y01M09]
, [FG_Test_Monthly_Y01M10]
, [FG_Test_Monthly_Y01M11]
, [FG_Test_Monthly_Y01M12]

, [FG_Test_Monthly_Y02M01]
, [FG_Test_Monthly_Y02M02]
, [FG_Test_Monthly_Y02M03]
, [FG_Test_Monthly_Y02M04]
, [FG_Test_Monthly_Y02M05]
, [FG_Test_Monthly_Y02M06]
, [FG_Test_Monthly_Y02M07]
, [FG_Test_Monthly_Y02M08]
, [FG_Test_Monthly_Y02M09]
, [FG_Test_Monthly_Y02M10]
, [FG_Test_Monthly_Y02M11]
, [FG_Test_Monthly_Y02M12]

, [FG_Test_Monthly_Y03M01]
, [FG_Test_Monthly_Y03M02]
, [FG_Test_Monthly_Y03M03]
, [FG_Test_Monthly_Y03M04]
, [FG_Test_Monthly_Y03M05]
, [FG_Test_Monthly_Y03M06]
, [FG_Test_Monthly_Y03M07]
, [FG_Test_Monthly_Y03M08]
, [FG_Test_Monthly_Y03M09]
, [FG_Test_Monthly_Y03M10]
, [FG_Test_Monthly_Y03M11]
, [FG_Test_Monthly_Y03M12]

)


create Table Test_Monthly
(
DataDate date
, Remark nvarchar(64) null
)
on ups_test_monthly(datadate)

Expand Down Expand Up @@ -1086,7 +1094,7 @@ ON

end
GO
/****** Object: StoredProcedure [dbo].[zsp_GenerateSampleMonthlyData] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: StoredProcedure [dbo].[zsp_GenerateSampleMonthlyData] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down Expand Up @@ -1169,7 +1177,7 @@ order by

end
GO
/****** Object: StoredProcedure [dbo].[zsp_MonthlyRollForwardPartitionsOnce] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: StoredProcedure [dbo].[zsp_MonthlyRollForwardPartitionsOnce] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down Expand Up @@ -1349,7 +1357,7 @@ end
end

GO
/****** Object: StoredProcedure [dbo].[zsp_MonthlyRollForwardsPartitionsOnDemand] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: StoredProcedure [dbo].[zsp_MonthlyRollForwardsPartitionsOnDemand] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down Expand Up @@ -1413,7 +1421,7 @@ begin
end

GO
/****** Object: StoredProcedure [dbo].[zsp_SampleMonthlyDataPartitionsInfoQuery] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: StoredProcedure [dbo].[zsp_SampleMonthlyDataPartitionsInfoQuery] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down Expand Up @@ -1453,17 +1461,16 @@ as
Test_Monthly a
)
SELECT
--$partition.
a.PartitionNumber
, a.FileGroupName
, a.LeftValue as [LeftInclusiveValue]
, a.RightValue as [RightExclusiveValue]
, a.StorageRows
, sum(a.StorageRows) over () as [Total StorageRows]
, min(b.DataDate) AS [Min Data Value]
, max(b.DataDate) AS [Max Data Value]
, count(b.DataDate) AS [Rows In Partition]
, sum(count(b.DataDate)) over () AS [Total Rows In All Partitions]
, min(b.DataDate) as [Min Data Value]
, max(b.DataDate) as [Max Data Value]
, count(b.DataDate) as [Rows In Partition]
, sum(count(b.DataDate)) over () as [Total Rows In All Partitions]
FROM
TPartitions a
left join
Expand All @@ -1482,7 +1489,7 @@ ORDER BY

end
GO
/****** Object: StoredProcedure [dbo].[zsp_TablesPartitionsInfoQuery] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: StoredProcedure [dbo].[zsp_TablesPartitionsInfoQuery] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand All @@ -1505,7 +1512,7 @@ order by

end
GO
/****** Object: StoredProcedure [dbo].[zsp_TablesPartitionsStorage] Script Date: 11/20/2019 12:32:14 PM ******/
/****** Object: StoredProcedure [dbo].[zsp_TablesPartitionsStorage] Script Date: 11/22/2019 1:49:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
Expand Down
Binary file modified MonthlyPartitionsTest.Database.sql
Binary file not shown.
Binary file modified UPF_Test_Monthly.PartitionFunction.sql
Binary file not shown.
Binary file modified UPS_Test_Monthly.PartitionScheme.sql
Binary file not shown.
Binary file modified dbo.SVF_GetMonthlyExclusivePartitionNo.UserDefinedFunction.sql
Binary file not shown.
Binary file modified dbo.SVF_GetMonthlyPartitionNo.UserDefinedFunction.sql
Binary file not shown.
Binary file modified dbo.Test_Monthly.Table.sql
Binary file not shown.
Binary file modified dbo.iTVF_TablesPartitionsInfo.UserDefinedFunction.sql
Binary file not shown.
Binary file modified dbo.iTVF_TablesPartitionsStorageInfo.UserDefinedFunction.sql
Binary file not shown.
Binary file modified dbo.zsp_CreateSampleTable.StoredProcedure.sql
Binary file not shown.
Binary file modified dbo.zsp_GenerateSampleMonthlyData.StoredProcedure.sql
Binary file not shown.
Binary file modified dbo.zsp_MonthlyRollForwardPartitionsOnce.StoredProcedure.sql
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified dbo.zsp_TablesPartitionsInfoQuery.StoredProcedure.sql
Binary file not shown.
Binary file modified dbo.zsp_TablesPartitionsStorage.StoredProcedure.sql
Binary file not shown.

0 comments on commit 7a0c7f6

Please sign in to comment.