Created
March 19, 2013 02:21
-
-
Save markmo/5193225 to your computer and use it in GitHub Desktop.
Create Tally Table - useful for removing and creating duplicates
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 and populate the Tally table on the fly | |
SELECT TOP 11000 --equates to more than 30 years of dates | |
IDENTITY(INT,1,1) AS N | |
INTO dbo.Tally | |
FROM Master.dbo.SysColumns sc1, | |
Master.dbo.SysColumns sc2 | |
--===== Add a Primary Key to maximize performance | |
ALTER TABLE dbo.Tally | |
ADD CONSTRAINT PK_Tally_N | |
PRIMARY KEY CLUSTERED (N) WITH FILLFACTOR = 100 | |
--===== Allow the general public to use it | |
GRANT SELECT ON dbo.Tally TO PUBLIC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment