Skip to content

Commit

Permalink
sp_helpme - add incl col (#267)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
lowlydba and lowlydba authored Jan 24, 2023
1 parent ee62ae8 commit beb9f04
Show file tree
Hide file tree
Showing 19 changed files with 190 additions and 272 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ jobs:
- name: Commit bundled installer script
uses: stefanzweifel/[email protected]
with:
commit_message: Updated bundled installer
commit_message: Updated bundled installer [skip ci]
file_pattern: ${{ env.INSTALLER_FILE }}
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
branches:
- main
pull_request:
paths-ignore:
- install_dba-multitool.sql

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sqlserver-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ jobs:
- name: Update SqlServer Module
run: |
Install-Module SqlServer -AllowClobber -AllowPreRelease -Force
- name: Install multitool
run: |
foreach ($script in (Get-ChildItem -Path "." -Filter "sp_*.sql").Name) {
Invoke-Sqlcmd -ServerInstance $Env:SQLINSTANCE -Database $Env:DATABASE -InputFile $script
Invoke-Sqlcmd -InputFile $script -ConnectionString "Data Source=$Env:SQLINSTANCE;Initial Catalog=$Env:DATABASE;Integrated Security=True;TrustServerCertificate=true"
}
- name: Run Pester tests with SQLCover
Expand All @@ -105,7 +105,7 @@ jobs:
run: |
Write-Output "Generating '$Env:SAMPLE_DATABASE' markdown sample."
$Query = "EXEC sp_doc @DatabaseName = '$Env:SAMPLE_DATABASE';"
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"
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"
- name: Upload sp_doc sample artifact
uses: actions/upload-artifact@v3
Expand Down
47 changes: 0 additions & 47 deletions appveyor/appveyor.yml

This file was deleted.

29 changes: 0 additions & 29 deletions appveyor/install_dependencies.ps1

This file was deleted.

71 changes: 0 additions & 71 deletions appveyor/install_tsqlt.ps1

This file was deleted.

49 changes: 0 additions & 49 deletions appveyor/run_pester_tests.ps1

This file was deleted.

16 changes: 0 additions & 16 deletions appveyor/start_sqlserver.ps1

This file was deleted.

12 changes: 2 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ optimizing storage, on-the-fly documentation, general administrative needs,
and more. Each script relies solely on T-SQL to ensure it is secure,
requires no third-party software, and can be installed in seconds.

All open source, all free to use under the MIT license.

Check the below list for technical documentation on each script.

## Scripts

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

## Compatibility

Tested against versions that are still in the standard support lifecycle.
Only support for versions that are still in [mainstream][mainstream] support is guaranteed.

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

[appveyor]: https://ci.appveyor.com/project/LowlyDBA/dba-multitool
[azure-badge]: https://img.shields.io/badge/Azure%20SQL-vCurrent-blue?logo=data:image/svg+xml;base64,PHN2ZyBkYXRhLXNsdWctaWQ9InNxbC1kYXRhYmFzZS1ibHVlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OSA0OSI+DQogIDxwYXRoIGQ9Im02LjQwNDIxIDcuNDA0NDJ2MzQuMTk1NzhjMCAzLjUyNDMgNy44ODk2OSA2LjQ3NzIgMTcuNjgwMzkgNi40Nzcydi00MC42NzI5OHoiIGZpbGw9IiM4MDgwODAiLz4NCiAgPHBhdGggZD0ibTIzLjg5NDYgNDguMDc3NGguMjg1MmM5Ljc5MDcgMCAxNy42ODA0LTIuODU3NiAxNy42ODA0LTYuNDc3MnYtMzQuMTk1NzhoLTE3Ljk2NTZ6IiBmaWxsPSIjODA4MDgwIi8+DQogIDxwYXRoIGQ9Im0yMy43MDQzIDQ4LjA3NzloLjI4NTJjOS44ODU4IDAgMTcuOTY1Ni0yLjg1NzYgMTcuOTY1Ni02LjQ3NzJ2LTM0LjI5MTAxaC0xOC4xNTU3eiIgZmlsbD0iIzgwODA4MCIvPg0KICA8cGF0aCBkPSJtNDEuODU4NCA3LjQwNTUzYzAgMy41MjQzNy03Ljg4OTcgNi40NzcxNy0xNy42ODA1IDYuNDc3MTctOS43OTA3IDAtMTcuNjgwMzktMi44NTc2LTE3LjY4MDM5LTYuNDc3MTcgMC0zLjYxOTYgNy44ODk2OS02LjQ3NzE4NSAxNy42ODAzOS02LjQ3NzE4NSA5Ljc5MDggMCAxNy42ODA1IDIuOTUyODM1IDE3LjY4MDUgNi40NzcxODV6IiBmaWxsPSIjZmZmIi8+PHBhdGggZD0ibTM4LjI0ODEgNy4wMjM4YzAgMi4zODEzMi02LjI3MzcgNC4yODY0LTE0LjA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EuODA5OC0uNjY1NC0yLjg1NzYgMC0xLjE0My4xOTAxLTIuMTkwOC42NjU0LTMuMTQzMy40NzUzLS45NTI2IDEuMTQwNi0xLjYxOTMgMS45OTYyLTIuMDk1Ni44NTU1LS40NzYzIDEuODA2LS43NjIgMi45NDY3LS43NjIgMS4wNDU2IDAgMS45OTYyLjE5MDUgMi43NTY2LjY2NjguODU1NS40NzYyIDEuNDI1OSAxLjE0MyAxLjkwMTEgMi4wMDAzLjM4MDMuOTUyNS41NzA0IDEuOTA1LjU3MDQgMy4wNDgxeiIvPjxwYXRoIGQ9Im0zOS4xMDM2IDM0LjI2NTNoLTYuNzQ5di0xMS4xNDQ2aDIuNTY2NnY5LjE0NDNoNC4xODI0eiIvPg0KICA8L2c+DQo8L3N2Zz4NCg==
[codecov]: https://codecov.io/gh/LowlyDBA/dba-multitool
[contrib]: ../.github/CONTRIBUTING.md
[dbatools]: https://dbatools.io
[issue]: https://github.com/LowlyDBA/dba-multitool/issues
[license]: ../LICENSE
[lint]: https://github.com/LowlyDBA/dba-multitool/actions?query=workflow%3A%22Lint+Code+Base%22
[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
[slack]: https://sqlcommunity.slack.com/archives/C026Y2YCM9N
[sp_doc]: https://dba-multitool.org/sp_doc
[sp_estindex]: https://dba-multitool.org/sp_estindex
[sp_helpme]: https://dba-multitool.org/sp_helpme
[sp_sizeoptimiser]: https://dba-multitool.org/sp_sizeoptimiser
[sqlserver-badge]: https://img.shields.io/badge/SQL%20Server-2012--2019-blue?logo=microsoft-sql-server
61 changes: 56 additions & 5 deletions install_dba-multitool.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Version: 20211223
MIT License
Copyright (c) 2022 John McCall
Copyright (c) 2023 John McCall
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
Expand Down Expand Up @@ -2356,7 +2356,7 @@ Version: 20220124
MIT License
Copyright (c) 2022 John McCall
Copyright (c) 2023 John McCall
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
Expand Down Expand Up @@ -3205,11 +3205,11 @@ sp_helpme - A drop-in modern alternative to sp_help.
Part of the DBA MultiTool http://dba-multitool.org
Version: 20220124
Version: 20230108
MIT License
Copyright (c) 2022 John McCall
Copyright (c) 2023 John McCall
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
Expand Down Expand Up @@ -3570,7 +3570,58 @@ BEGIN
IF @SysObj_Type IN ('S ','U ')
BEGIN
EXEC sys.sp_objectfilegroup @ObjID;

/* Begin custom included columns for sp_helpindex */
CREATE TABLE #sp_helpindex (
index_name SYSNAME COLLATE database_default
,index_description VARCHAR(210)
,index_keys NVARCHAR(2126) COLLATE database_default --Length (16*max_identifierLength)+(15*2)+(16*3)
,index_includes NVARCHAR(MAX) --Length (1023*max_identifierLength)+(15*2)+(16*3) is > 4000
);
INSERT INTO #sp_helpindex (index_name, index_description, index_keys)
EXEC sys.sp_helpindex @ObjectName;

IF EXISTS (SELECT 1 FROM #sp_helpindex)
BEGIN
SET @SQLString = N'
WITH includedColumns AS (
SELECT DISTINCT i2.name AS index_name
, LTRIM(STUFF((
SELECT '', '' + c.name
FROM sys.indexes i
INNER JOIN ' + QUOTENAME(DB_NAME()) + '.sys.index_columns ic ON i.index_id = ic.index_id
INNER JOIN ' + QUOTENAME(DB_NAME()) + '.sys.columns c ON c.column_id = ic.column_id
WHERE i.object_id = @ObjID
AND ic.object_id = @ObjID
AND c.object_id = @ObjID
AND ic.is_included_column = 1
AND i2.index_id = i.index_id
FOR XML PATH(''''), TYPE).value(''.'', ''NVARCHAR(MAX)''), 1, 1, '''')) AS included
FROM ' + QUOTENAME(DB_NAME()) + '.sys.indexes i2
INNER JOIN #sp_helpindex sp ON sp.index_name COLLATE database_default = i2.name
INNER JOIN ' + QUOTENAME(DB_NAME()) + '.sys.index_columns ic ON i2.index_id = ic.index_id
WHERE i2.object_id = @ObjID
AND ic.object_id = @ObjID
AND ic.is_included_column = 1
)
UPDATE sp
SET sp.index_includes = ic.included
FROM #sp_helpindex sp
INNER JOIN includedColumns ic ON sp.index_name COLLATE database_default = ic.index_name;';
SET @ParmDefinition = N'@ObjID INT';

EXEC sp_executesql @SQLString
,@ParmDefinition
,@ObjID;
END

IF EXISTS (SELECT 1 FROM #sp_helpindex)
BEGIN
SELECT index_name, index_description, index_keys, index_includes
FROM #sp_helpindex;
END
/* End custom included columns for sp_helpindex */

EXEC sys.sp_helpconstraint @ObjectName,'nomsg';

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

0 comments on commit beb9f04

Please sign in to comment.