Skip to content

Commit 32c3613

Browse files
authored
Merge pull request #158 from LowlyDBA/development
Misc. Small Fixes
2 parents 99ac3e5 + 04d47ca commit 32c3613

File tree

11 files changed

+216
-193
lines changed

11 files changed

+216
-193
lines changed

appveyor/sqlcover/Coverage.opencoverxml

Lines changed: 154 additions & 154 deletions
Large diffs are not rendered by default.

appveyor/sqlcover/[dbo].[sp_estindex]

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sp_estindex - Estimate a new index's size and statistics.
2121

2222
Part of the DBA MultiTool http://dba-multitool.org
2323

24-
Version: 20201016
24+
Version: 20201109
2525

2626
MIT License
2727

@@ -213,21 +213,21 @@ BEGIN TRY
213213

214214
--Get index columns in same format as dmv table
215215
SET @Sql = CONCAT(@UseDatabase,
216-
N'SELECT @QuotedKeyColumns = CASE [ic].[is_included_column] WHEN 0
217-
THEN COALESCE(@QuotedKeyColumns + '', '', '''') + QUOTENAME([ac].[name])
218-
ELSE @QuotedKeyColumns
216+
N'SELECT @QuotedKeyColumns = CASE WHEN [ic].[is_included_column] = 0
217+
THEN CONCAT(COALESCE(@QuotedKeyColumns COLLATE DATABASE_DEFAULT + '', '', ''''), QUOTENAME([ac].[name]))
218+
ELSE @QuotedKeyColumns
219219
END,
220-
@QuotedInclColumns = CASE [ic].[is_included_column] WHEN 1
221-
THEN COALESCE(@QuotedInclColumns + '', '', '''') + QUOTENAME([ac].[name])
222-
ELSE @QuotedInclColumns
223-
END
224-
FROM [sys].[indexes] AS [i]
220+
@QuotedInclColumns = CASE WHEN [ic].[is_included_column] = 1
221+
THEN CONCAT(COALESCE(@QuotedInclColumns COLLATE DATABASE_DEFAULT + '', '', ''''), QUOTENAME([ac].[name]))
222+
ELSE @QuotedInclColumns
223+
END
224+
FROM [sys].[indexes] AS [i]
225225
INNER JOIN [sys].[index_columns] AS [ic] ON [i].[index_id] = [ic].[index_id]
226226
AND [ic].object_id = [i].object_id
227-
INNER JOIN [sys].[all_columns] AS [ac] ON [ac].object_id = [ic].object_id
227+
INNER JOIN [sys].[all_columns] AS [ac] ON [ac].[object_id] = [ic].[object_id]
228228
AND [ac].[column_id] = [ic].[column_id]
229229
WHERE [i].[name] = @IndexName
230-
AND [i].[object_id] = @ObjectID
230+
AND [i].[object_id] = @ObjectID
231231
AND [i].[is_hypothetical] = 1;');
232232
SET @ParmDefinition = N'@IndexName SYSNAME, @ObjectID INT, @QuotedKeyColumns NVARCHAR(2048) OUTPUT, @QuotedInclColumns NVARCHAR(2048) OUTPUT';
233233
EXEC sp_executesql @Sql

docs/assets/sp_estindex_output.png

31.3 KB
Loading

docs/assets/sp_helpme_output.PNG

127 KB
Loading
221 KB
Loading

docs/sp_doc.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* [Purpose](#purpose)
1111
* [Arguments](#arguments)
1212
* [Usage](#usage)
13-
* [Sample](#sample)
13+
* [Output](#output)
1414
* [Contributing](#contributing)
1515
* [More](#more)
1616

@@ -91,9 +91,9 @@ EXEC sys.sp_addextendedproperty @name=N'@ExtendedPropertyName',
9191
@level1name=N'sp_doc'
9292
```
9393

94-
## Sample
94+
## Output
9595

96-
Output for the [WideWorldImporters database][sample].
96+
Sample output for the [WideWorldImporters database][sample].
9797

9898
*Note: Slight changes may be made to this database to better demo script capabilities.*
9999

docs/sp_estindex.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [Purpose](#purpose)
1111
* [Arguments](#arguments)
1212
* [Usage](#usage)
13+
* [Output](#output)
1314
* [Contributing](#contributing)
1415
* [More](#more)
1516

@@ -50,6 +51,15 @@ EXEC dbo.sp_estindex @SchemaName = 'dbo', @tableName = 'Marathon', @IndexColumns
5051
EXEC dbo.sp_estindex @tableName = 'Marathon', @IndexColumns = 'racer_id, finish_time', @Filter = 'WHERE racer_id IS NOT NULL', @FillFactor = 90;
5152
```
5253

54+
## Output
55+
56+
For `[Sales].[Invoices]` in WorldWideImporters:
57+
58+
*Note: There is no missing index match in this example,
59+
so the penultimate result set is empty.*
60+
61+
![sp_estindex output](assets/sp_estindex_output.png)
62+
5363
## Contributing
5464

5565
Missing a feature? Found a bug? Open an [issue][issue] to get some :heart:

docs/sp_helpme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@ Changes from the original include:
3838
Basic example:
3939

4040
```tsql
41-
EXEC sp_helpme 'dbo.Sales';
41+
EXEC sp_helpme 'Sales.Invoices';
4242
```
4343

44+
## Output
45+
46+
For `[Sales].[Invoices]` in WideWorldImporters:
47+
48+
![sp_helpme output](assets/sp_helpme_output.PNG)
49+
4450
## Contributing
4551

4652
Missing a feature? Found a bug? Open an [issue][issue] to get some :heart:

docs/sp_sizeoptimiser.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [Purpose](#purpose)
1111
* [Arguments](#arguments)
1212
* [Usage](#usage)
13+
* [Output](#output)
1314
* [Checks](#checks)
1415
* [Contributing](#contributing)
1516
* [More](#more)
@@ -51,6 +52,12 @@ EXEC [dbo].[sp_sizeoptimiser] @IncludeDatabases = @includeDatabases;
5152
GO
5253
```
5354

55+
## Output
56+
57+
For WorldWideImporters:
58+
59+
![sp_sizeoptimiser output](assets/sp_sizeoptimiser_output.png)
60+
5461
## Checks
5562

5663
There are 17 checks currently supported:

install_dba-multitool.sql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ sp_estindex - Estimate a new index's size and statistics.
12921292
12931293
Part of the DBA MultiTool http://dba-multitool.org
12941294
1295-
Version: 20201016
1295+
Version: 20201109
12961296
12971297
MIT License
12981298
@@ -1484,21 +1484,21 @@ BEGIN TRY
14841484

14851485
--Get index columns in same format as dmv table
14861486
SET @Sql = CONCAT(@UseDatabase,
1487-
N'SELECT @QuotedKeyColumns = CASE [ic].[is_included_column] WHEN 0
1488-
THEN COALESCE(@QuotedKeyColumns + '', '', '''') + QUOTENAME([ac].[name])
1489-
ELSE @QuotedKeyColumns
1487+
N'SELECT @QuotedKeyColumns = CASE WHEN [ic].[is_included_column] = 0
1488+
THEN CONCAT(COALESCE(@QuotedKeyColumns COLLATE DATABASE_DEFAULT + '', '', ''''), QUOTENAME([ac].[name]))
1489+
ELSE @QuotedKeyColumns
14901490
END,
1491-
@QuotedInclColumns = CASE [ic].[is_included_column] WHEN 1
1492-
THEN COALESCE(@QuotedInclColumns + '', '', '''') + QUOTENAME([ac].[name])
1493-
ELSE @QuotedInclColumns
1494-
END
1495-
FROM [sys].[indexes] AS [i]
1491+
@QuotedInclColumns = CASE WHEN [ic].[is_included_column] = 1
1492+
THEN CONCAT(COALESCE(@QuotedInclColumns COLLATE DATABASE_DEFAULT + '', '', ''''), QUOTENAME([ac].[name]))
1493+
ELSE @QuotedInclColumns
1494+
END
1495+
FROM [sys].[indexes] AS [i]
14961496
INNER JOIN [sys].[index_columns] AS [ic] ON [i].[index_id] = [ic].[index_id]
14971497
AND [ic].object_id = [i].object_id
1498-
INNER JOIN [sys].[all_columns] AS [ac] ON [ac].object_id = [ic].object_id
1498+
INNER JOIN [sys].[all_columns] AS [ac] ON [ac].[object_id] = [ic].[object_id]
14991499
AND [ac].[column_id] = [ic].[column_id]
15001500
WHERE [i].[name] = @IndexName
1501-
AND [i].[object_id] = @ObjectID
1501+
AND [i].[object_id] = @ObjectID
15021502
AND [i].[is_hypothetical] = 1;');
15031503
SET @ParmDefinition = N'@IndexName SYSNAME, @ObjectID INT, @QuotedKeyColumns NVARCHAR(2048) OUTPUT, @QuotedInclColumns NVARCHAR(2048) OUTPUT';
15041504
EXEC sp_executesql @Sql
@@ -2037,10 +2037,10 @@ GO
20372037
EXEC sys.sp_addextendedproperty @name=N'@DatabaseName', @value=N'Target database of the index''s table.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex';
20382038
GO
20392039

2040-
EXEC sys.sp_addextendedproperty @name=N'@FillFactor', @value=N'Optional fill factor for the index.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex';
2040+
EXEC sys.sp_addextendedproperty @name=N'@FillFactor', @value=N'Optional fill factor for the index. Default is 100.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex';
20412041
GO
20422042

2043-
EXEC sys.sp_addextendedproperty @name=N'@Filter', @value=N'Optional filter for the index. Default is 100.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex';
2043+
EXEC sys.sp_addextendedproperty @name=N'@Filter', @value=N'Optional filter for the index.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex';
20442044
GO
20452045

20462046
EXEC sys.sp_addextendedproperty @name=N'@IncludeColumns', @value=N'Optional comma separated list of include columns.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex';

0 commit comments

Comments
 (0)