Skip to content

Commit beb9f04

Browse files
authored
sp_helpme - add incl col (#267)
* remove accident file * add included cols for index output * update copyright date * Updated bundled installer * follow column naming convention * Updated bundled installer * remove appveyor ci * exclude lint rule * Updated bundled installer * clean up docs * only return result set if rows * improve unit test independence from tsqlt schema * Updated bundled installer * improve unit tests * fix typo * fix test * ignore lint for autogen file * skip ci for artifact * fix db context * pluralize col to match existing * Updated bundled installer [skip ci] * tsqllint cant peek inside dynamic sql * Updated bundled installer [skip ci] * fix ssl issues * fix ssl in unit tests * fix sp_doc artifact ssl issue Co-authored-by: lowlydba <[email protected]>
1 parent ee62ae8 commit beb9f04

19 files changed

+190
-272
lines changed

.github/workflows/artifacts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ jobs:
4242
- name: Commit bundled installer script
4343
uses: stefanzweifel/[email protected]
4444
with:
45-
commit_message: Updated bundled installer
45+
commit_message: Updated bundled installer [skip ci]
4646
file_pattern: ${{ env.INSTALLER_FILE }}

.github/workflows/lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
branches:
99
- main
1010
pull_request:
11+
paths-ignore:
12+
- install_dba-multitool.sql
1113

1214
jobs:
1315
build:

.github/workflows/sqlserver-unit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ jobs:
8080
- name: Update SqlServer Module
8181
run: |
8282
Install-Module SqlServer -AllowClobber -AllowPreRelease -Force
83-
83+
8484
- name: Install multitool
8585
run: |
8686
foreach ($script in (Get-ChildItem -Path "." -Filter "sp_*.sql").Name) {
87-
Invoke-Sqlcmd -ServerInstance $Env:SQLINSTANCE -Database $Env:DATABASE -InputFile $script
87+
Invoke-Sqlcmd -InputFile $script -ConnectionString "Data Source=$Env:SQLINSTANCE;Initial Catalog=$Env:DATABASE;Integrated Security=True;TrustServerCertificate=true"
8888
}
8989
9090
- name: Run Pester tests with SQLCover
@@ -105,7 +105,7 @@ jobs:
105105
run: |
106106
Write-Output "Generating '$Env:SAMPLE_DATABASE' markdown sample."
107107
$Query = "EXEC sp_doc @DatabaseName = '$Env:SAMPLE_DATABASE';"
108-
Invoke-SqlCmd -ServerInstance $Env:SQLINSTANCE -Database $Env:DATABASE -Query $Query -As DataRows | Select-Object -ExpandProperty 'value' | Out-File "$($Env:SAMPLE_DATABASE)-$($Env:SQL_VERSION).md"
108+
Invoke-SqlCmd -Query $Query -As DataRows -ConnectionString "Data Source=$Env:SQLINSTANCE;Initial Catalog=$Env:DATABASE;Integrated Security=True;TrustServerCertificate=true" | Select-Object -ExpandProperty 'value' | Out-File "$($Env:SAMPLE_DATABASE)-$($Env:SQL_VERSION).md"
109109
110110
- name: Upload sp_doc sample artifact
111111
uses: actions/upload-artifact@v3

appveyor/appveyor.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

appveyor/install_dependencies.ps1

Lines changed: 0 additions & 29 deletions
This file was deleted.

appveyor/install_tsqlt.ps1

Lines changed: 0 additions & 71 deletions
This file was deleted.

appveyor/run_pester_tests.ps1

Lines changed: 0 additions & 49 deletions
This file was deleted.

appveyor/start_sqlserver.ps1

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ optimizing storage, on-the-fly documentation, general administrative needs,
1414
and more. Each script relies solely on T-SQL to ensure it is secure,
1515
requires no third-party software, and can be installed in seconds.
1616

17-
All open source, all free to use under the MIT license.
18-
19-
Check the below list for technical documentation on each script.
20-
2117
## Scripts
2218

2319
To quickly install/update all the scripts, use install_dba-multitool.sql
@@ -34,7 +30,7 @@ For detailed instructions and documentation, see [dba-multitool.org](https://dba
3430

3531
## Compatibility
3632

37-
Tested against versions that are still in the standard support lifecycle.
33+
Only support for versions that are still in [mainstream][mainstream] support is guaranteed.
3834

3935
| Version | Tested |
4036
| ------- | :----: |
@@ -57,17 +53,13 @@ Tested against versions that are still in the standard support lifecycle.
5753
<sub>*Icon made by [mangsaabguru](https://www.flaticon.com/authors/mangsaabguru)
5854
from [www.flaticon.com](https://www.flaticon.com/)*</sub>
5955

60-
[appveyor]: https://ci.appveyor.com/project/LowlyDBA/dba-multitool
61-
[azure-badge]: https://img.shields.io/badge/Azure%20SQL-vCurrent-blue?logo=data:image/svg+xml;base64,PHN2ZyBkYXRhLXNsdWctaWQ9InNxbC1kYXRhYmFzZS1ibHVlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OSA0OSI+DQogIDxwYXRoIGQ9Im02LjQwNDIxIDcuNDA0NDJ2MzQuMTk1NzhjMCAzLjUyNDMgNy44ODk2OSA2LjQ3NzIgMTcuNjgwMzkgNi40Nzcydi00MC42NzI5OHoiIGZpbGw9IiM4MDgwODAiLz4NCiAgPHBhdGggZD0ibTIzLjg5NDYgNDguMDc3NGguMjg1MmM5Ljc5MDcgMCAxNy42ODA0LTIuODU3NiAxNy42ODA0LTYuNDc3MnYtMzQuMTk1NzhoLTE3Ljk2NTZ6IiBmaWxsPSIjODA4MDgwIi8+DQogIDxwYXRoIGQ9Im0yMy43MDQzIDQ4LjA3NzloLjI4NTJjOS44ODU4IDAgMTcuOTY1Ni0yLjg1NzYgMTcuOTY1Ni02LjQ3NzJ2LTM0LjI5MTAxaC0xOC4xNTU3eiIgZmlsbD0iIzgwODA4MCIvPg0KICA8cGF0aCBkPSJtNDEuODU4NCA3LjQwNTUzYzAgMy41MjQzNy03Ljg4OTcgNi40NzcxNy0xNy42ODA1IDYuNDc3MTctOS43OTA3IDAtMTcuNjgwMzktMi44NTc2LTE3LjY4MDM5LTYuNDc3MTcgMC0zLjYxOTYgNy44ODk2OS02LjQ3NzE4NSAxNy42ODAzOS02LjQ3NzE4NSA5Ljc5MDggMCAxNy42ODA1IDIuOTUyODM1IDE3LjY4MDUgNi40NzcxODV6IiBmaWxsPSIjZmZmIi8+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zYwNC0uNDc2My0xLjQyNTgtMS4xNDMtMS44MDYtMi4wMDAzLS40NzUzLS44NTczLS42NjU0LTEuODA5OC0uNjY1NC0yLjg1NzYgMC0xLjE0My4xOTAxLTIuMTkwOC42NjU0LTMuMTQzMy40NzUzLS45NTI2IDEuMTQwNi0xLjYxOTMgMS45OTYyLTIuMDk1Ni44NTU1LS40NzYzIDEuODA2LS43NjIgMi45NDY3LS43NjIgMS4wNDU2IDAgMS45OTYyLjE5MDUgMi43NTY2LjY2NjguODU1NS40NzYyIDEuNDI1OSAxLjE0MyAxLjkwMTEgMi4wMDAzLjM4MDMuOTUyNS41NzA0IDEuOTA1LjU3MDQgMy4wNDgxeiIvPjxwYXRoIGQ9Im0zOS4xMDM2IDM0LjI2NTNoLTYuNzQ5di0xMS4xNDQ2aDIuNTY2NnY5LjE0NDNoNC4xODI0eiIvPg0KICA8L2c+DQo8L3N2Zz4NCg==
62-
[codecov]: https://codecov.io/gh/LowlyDBA/dba-multitool
6356
[contrib]: ../.github/CONTRIBUTING.md
6457
[dbatools]: https://dbatools.io
6558
[issue]: https://github.com/LowlyDBA/dba-multitool/issues
6659
[license]: ../LICENSE
67-
[lint]: https://github.com/LowlyDBA/dba-multitool/actions?query=workflow%3A%22Lint+Code+Base%22
60+
[mainstream]: https://learn.microsoft.com/en-us/sql/sql-server/end-of-support/sql-server-end-of-support-overview?view=sql-server-ver16#lifecycle-dates
6861
[slack]: https://sqlcommunity.slack.com/archives/C026Y2YCM9N
6962
[sp_doc]: https://dba-multitool.org/sp_doc
7063
[sp_estindex]: https://dba-multitool.org/sp_estindex
7164
[sp_helpme]: https://dba-multitool.org/sp_helpme
7265
[sp_sizeoptimiser]: https://dba-multitool.org/sp_sizeoptimiser
73-
[sqlserver-badge]: https://img.shields.io/badge/SQL%20Server-2012--2019-blue?logo=microsoft-sql-server

install_dba-multitool.sql

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Version: 20211223
9090
9191
MIT License
9292
93-
Copyright (c) 2022 John McCall
93+
Copyright (c) 2023 John McCall
9494
9595
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
9696
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
@@ -2356,7 +2356,7 @@ Version: 20220124
23562356
23572357
MIT License
23582358
2359-
Copyright (c) 2022 John McCall
2359+
Copyright (c) 2023 John McCall
23602360
23612361
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
23622362
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
@@ -3205,11 +3205,11 @@ sp_helpme - A drop-in modern alternative to sp_help.
32053205
32063206
Part of the DBA MultiTool http://dba-multitool.org
32073207
3208-
Version: 20220124
3208+
Version: 20230108
32093209
32103210
MIT License
32113211
3212-
Copyright (c) 2022 John McCall
3212+
Copyright (c) 2023 John McCall
32133213
32143214
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
32153215
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
@@ -3570,7 +3570,58 @@ BEGIN
35703570
IF @SysObj_Type IN ('S ','U ')
35713571
BEGIN
35723572
EXEC sys.sp_objectfilegroup @ObjID;
3573+
3574+
/* Begin custom included columns for sp_helpindex */
3575+
CREATE TABLE #sp_helpindex (
3576+
index_name SYSNAME COLLATE database_default
3577+
,index_description VARCHAR(210)
3578+
,index_keys NVARCHAR(2126) COLLATE database_default --Length (16*max_identifierLength)+(15*2)+(16*3)
3579+
,index_includes NVARCHAR(MAX) --Length (1023*max_identifierLength)+(15*2)+(16*3) is > 4000
3580+
);
3581+
INSERT INTO #sp_helpindex (index_name, index_description, index_keys)
35733582
EXEC sys.sp_helpindex @ObjectName;
3583+
3584+
IF EXISTS (SELECT 1 FROM #sp_helpindex)
3585+
BEGIN
3586+
SET @SQLString = N'
3587+
WITH includedColumns AS (
3588+
SELECT DISTINCT i2.name AS index_name
3589+
, LTRIM(STUFF((
3590+
SELECT '', '' + c.name
3591+
FROM sys.indexes i
3592+
INNER JOIN ' + QUOTENAME(DB_NAME()) + '.sys.index_columns ic ON i.index_id = ic.index_id
3593+
INNER JOIN ' + QUOTENAME(DB_NAME()) + '.sys.columns c ON c.column_id = ic.column_id
3594+
WHERE i.object_id = @ObjID
3595+
AND ic.object_id = @ObjID
3596+
AND c.object_id = @ObjID
3597+
AND ic.is_included_column = 1
3598+
AND i2.index_id = i.index_id
3599+
FOR XML PATH(''''), TYPE).value(''.'', ''NVARCHAR(MAX)''), 1, 1, '''')) AS included
3600+
FROM ' + QUOTENAME(DB_NAME()) + '.sys.indexes i2
3601+
INNER JOIN #sp_helpindex sp ON sp.index_name COLLATE database_default = i2.name
3602+
INNER JOIN ' + QUOTENAME(DB_NAME()) + '.sys.index_columns ic ON i2.index_id = ic.index_id
3603+
WHERE i2.object_id = @ObjID
3604+
AND ic.object_id = @ObjID
3605+
AND ic.is_included_column = 1
3606+
)
3607+
UPDATE sp
3608+
SET sp.index_includes = ic.included
3609+
FROM #sp_helpindex sp
3610+
INNER JOIN includedColumns ic ON sp.index_name COLLATE database_default = ic.index_name;';
3611+
SET @ParmDefinition = N'@ObjID INT';
3612+
3613+
EXEC sp_executesql @SQLString
3614+
,@ParmDefinition
3615+
,@ObjID;
3616+
END
3617+
3618+
IF EXISTS (SELECT 1 FROM #sp_helpindex)
3619+
BEGIN
3620+
SELECT index_name, index_description, index_keys, index_includes
3621+
FROM #sp_helpindex;
3622+
END
3623+
/* End custom included columns for sp_helpindex */
3624+
35743625
EXEC sys.sp_helpconstraint @ObjectName,'nomsg';
35753626

35763627
SET @SQLString = N'SELECT @HasDepen = COUNT(1)
@@ -3753,7 +3804,7 @@ Version: 20220818
37533804
37543805
MIT License
37553806
3756-
Copyright (c) 2022 John McCall
3807+
Copyright (c) 2023 John McCall
37573808
37583809
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
37593810
documentation files (the "Software"), to deal in the Software without restriction, including without limitation

0 commit comments

Comments
 (0)