Created
June 8, 2016 14:41
-
-
Save strvmarv/cd6abd4769c657c4903ce7fb9f8b518d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[sproc_Imagination_TruncatePartitions] | |
@start DATETIME, | |
@end DATETIME | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
DECLARE @partitions TABLE (Number SMALLINT) | |
INSERT INTO @partitions SELECT Number FROM dbo.udf_GetDayOfTheYearRange_FromDate(@start, @end) | |
DECLARE @cnt INT = 0; | |
SELECT @cnt = COUNT(1) FROM @partitions | |
WHILE @cnt > 0 | |
BEGIN | |
DECLARE @partition SMALLINT | |
SELECT TOP (1) @partition = Number FROM @partitions | |
TRUNCATE TABLE Imagination_Partitioned WITH (PARTITIONS(@partition)) | |
DELETE TOP(1) FROM @partitions | |
SELECT @cnt = COUNT(1) FROM @partitions | |
END | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment