-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlserver.html
52 lines (38 loc) · 1.42 KB
/
sqlserver.html
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
52
<html>
<head>
<!-- makes browser more consistent -->
<link rel="stylesheet" href="css/normalize.css">
<!-- necessary for rainbow js -->
<link rel="stylesheet" href="css/solarized-light.css">
<!-- cheatsheet specific stylesheets -->
<link rel="stylesheet" href="css/cheatsheet.css">
</head>
<body>
<h1>Server Side Includes</h1>
<div class="container">
<article>
<h2>Snippets</h2>
<h3>No. of rows in each table</h3>
<p><strong>Deprecated</strong> but so far it works on all versions. This makes use of the fact that the number of rows are stored with each index. <code>o.xtype = 'U'</code> selects only user tables and <code>i.indid < 2</code> makes sure we select only one index per table. This can be a clustered index (1) or a heap index(0).</p>
<p><code class="multiline">SELECT o.name, i.rowcnt
FROM sysindexes AS i
INNER JOIN sysobjects AS o
ON i.id = o.id
WHERE i.indid < 2 AND o.xtype = 'U';</code></p>
</article>
<article>
<h2>Indexes</h2>
<dl>
<dt>Heap</dt>
<dd>Records are not stored in any particular order</dd>
<dt>Clustered</dt>
<dd>Records are stored according to this index (often primary key)</dd>
<dt>Non-Clustered</dt>
<dd>Only links to the records. Does not affect the way the records are stored</dd>
</article>
</div>
<!-- syntax highlighting -->
<script src="js\cheatsheet.js"></script>
<script src="js\rainbow-custom.min.js"></script>
</body>
</html>