forked from ktaranov/sqlserver-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate Numbers Table.snippet
51 lines (48 loc) · 1.82 KB
/
Create Numbers Table.snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<_locDefinition xmlns="urn:locstudio">
<_locDefault _loc="locNone" />
<_locTag _loc="locData">Title</_locTag>
<_locTag _loc="locData">Description</_locTag>
<_locTag _loc="locData">Author</_locTag>
<_locTag _loc="locData">ToolTip</_locTag>
</_locDefinition>
<CodeSnippet Format="1.0.0">
<Header>
<Title>Create Numbers table</Title>
<Shortcut></Shortcut>
<Description>Creates a numbers table and populates it with 10000 rows.</Description>
<Author>Matan Yungman</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>NumbersTableName</ID>
<ToolTip>Name of the numbers table</ToolTip>
<Default>#Numbers</Default>
</Literal>
<Literal>
<ID>TempTableName</ID>
<ToolTip>Name of the temporary table</ToolTip>
<Default>#T</Default>
</Literal>
</Declarations>
<Code Language="SQL">
<![CDATA[
create table $TempTableName$(col1 int)
go
insert $TempTableName$ select 1
go 10
create table $NumbersTableName$(id int primary key)
insert $NumbersTableName$(id)
select row_number() over(order by temp1.col1)
from $TempTableName$ temp1 cross join $TempTableName$ temp2
cross join $TempTableName$ temp3 cross join $TempTableName$ temp4
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>