initial population of repo
This commit is contained in:
6
cal-ca9ed7a3-6fb0-4d39-b918-887951161076.json
Normal file
6
cal-ca9ed7a3-6fb0-4d39-b918-887951161076.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id": "ca9ed7a3-6fb0-4d39-b918-887951161076",
|
||||
"prefix": "cal",
|
||||
"description": "create a calendar #cal table",
|
||||
"body": "--#region create calendar\r\nDECLARE @nb TABLE( val INT);\r\nINSERT INTO @nb(val)\r\nSELECT a=0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9;\r\n\r\nIF (SELECT OBJECT_ID('tempdb..#cal'))IS NOT NULL BEGIN\r\n\tDROP TABLE #cal;\r\nEND; \r\n\r\nSELECT * \r\nINTO #cal\r\nFROM (\r\n\tSELECT \r\n\t\tdtm=DATEADD(\r\n\t\t\tDAY\r\n\t\t\t, DATEDIFF(\r\n\t\t\t\tDAY\r\n\t\t\t\t, 0\r\n\t\t\t\t, DATEADD(\r\n\t\t\t\t\tDAY\r\n\t\t\t\t\t, ROW_NUMBER()OVER(ORDER BY a.val) * -1\r\n\t\t\t\t\t, CURRENT_TIMESTAMP\r\n\t\t\t\t)\r\n\t\t\t)\r\n\t\t\t, 1\r\n\t\t)\r\n\tFROM @nb a\r\n\t\tCROSS JOIN @nb b\r\n\t\tCROSS JOIN @nb c\r\n\t\tCROSS JOIN @nb d\r\n)x\r\nWHERE 1=1\r\nAND x.dtm BETWEEN @dtmFrom AND @dtmTo;\r\n--#endregion\r\n"
|
||||
}
|
||||
Reference in New Issue
Block a user