Skip to content

Commit 053fa4f

Browse files
committed
add args to docs & standardize param names
1 parent 3ec033e commit 053fa4f

File tree

5 files changed

+92
-37
lines changed

5 files changed

+92
-37
lines changed

docs/sp_doc.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[![codecov](https://codecov.io/gh/LowlyDBA/ExpressSQL/branch/master/graph/badge.svg)](https://codecov.io/gh/LowlyDBA/ExpressSQL)
1010

1111
* [Purpose](#purpose)
12+
* [Arguments](#arguments)
1213
* [Usage](#usage)
1314
* [Sample](#sample)
1415
* [Contributing](#contributing)
@@ -47,6 +48,16 @@ and plays nice with:
4748
* Gitlab Flavored Markdown
4849
* Any other CommonMark based renderer
4950

51+
## Arguments
52+
53+
* `@DatabaseName SYSNAME`
54+
55+
Target database to generate documentation for. If not supplied, the current database is used.
56+
57+
* `@ExtendedPropertyName VARCHAR(100)`
58+
59+
Name of the extended property containing descriptive text for objects. The default value is "Description".
60+
5061
## Usage
5162

5263
The primary parameter for this procedure is a database name, since the

docs/sp_helpme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[![codecov](https://codecov.io/gh/LowlyDBA/ExpressSQL/branch/master/graph/badge.svg)](https://codecov.io/gh/LowlyDBA/ExpressSQL)
1010

1111
* [Purpose](#purpose)
12+
* [Arguments](#arguments)
1213
* [Usage](#usage)
1314
* [Contributing](#contributing)
1415
* [More](#more)
@@ -24,6 +25,16 @@ Changes from the original include:
2425
* Including create, modify, and more metadata about objects
2526
* Referenced views are returned in two-part naming convention
2627

28+
## Arguments
29+
30+
* `@ObjectName SYSNAME`
31+
32+
Target non-database object to show information for. If not supplied, information on all objects in the database is returned.
33+
34+
* `@ExtendedPropertyName SYSNAME`
35+
36+
Name of the extended property containing descriptive text for objects. The default value is "Description".
37+
2738
## Usage
2839

2940
Basic example:

docs/sp_sizeoptimiser.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[![codecov](https://codecov.io/gh/LowlyDBA/ExpressSQL/branch/master/graph/badge.svg)](https://codecov.io/gh/LowlyDBA/ExpressSQL)
1010

1111
* [Purpose](#purpose)
12+
* [Arguments](#arguments)
1213
* [Usage](#usage)
1314
* [Checks](#checks)
1415
* [Contributing](#contributing)
@@ -23,6 +24,38 @@ useful for SQL Server Express to help stay under the 10GB file size limitations.
2324

2425
Storage is cheap, but smaller is faster!
2526

27+
## Arguments
28+
29+
* `@IndexNumThreshold SMALLINT`
30+
31+
Number of indexes to classify a table as having too many indexes on it.
32+
Default value is 10.
33+
34+
* `@IncludeDatabases [dbo].[SizeOptimiserTableType]`
35+
36+
Which databases to run the script on in the form of a user defined table type.
37+
If not supplied, all accessible user databases are targeted. Cannot be used in conjunction with `@ExcludeDatabases`.
38+
39+
* `@ExcludeDatabases [dbo].[SizeOptimiserTableType]`
40+
41+
Which databases to exclude in the form of a user defined table type.
42+
Cannot be used in conjunction with `@IncludeDatabases`.
43+
44+
* `@IncludeSysDatabases BIT`
45+
46+
Whether or not to include system databases in the script's analysis. Default is 0.
47+
48+
* `@IncludeSSRSDatabases BIT`
49+
50+
Whether or not to include SQL Server Reporting Services databases in the script's analysis.
51+
Default is 0.
52+
53+
* `@Verbose BIT`
54+
55+
Whether or not to print additional information during the script run,
56+
including which checks may be skipped and variable values.
57+
Default is 0.
58+
2659
## Usage
2760

2861
Basic example:

sp_doc.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ END
1111
GO
1212

1313
ALTER PROCEDURE [dbo].[sp_doc]
14-
@DatabaseName SYSNAME = NULL
15-
,@ExtendedPropertyName VARCHAR(100) = 'Description'
14+
@DatabaseName SYSNAME = NULL
15+
,@ExtendedPropertyName SYSNAME = 'Description'
1616
/* Parameters defined here for testing only */
1717
,@SqlMajorVersion TINYINT = 0
1818
,@SqlMinorVersion SMALLINT = 0

sp_helpme.sql

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ END
1111
GO
1212

1313
ALTER PROCEDURE [dbo].[sp_helpme]
14-
@objname SYSNAME = NULL
15-
,@epname SYSNAME = 'Description'
14+
@ObjectName SYSNAME = NULL
15+
,@ExtendedPropertyName SYSNAME = 'Description'
1616
/* Parameters defined here for testing only */
1717
,@SqlMajorVersion TINYINT = 0
1818
,@SqlMinorVersion SMALLINT = 0
@@ -95,8 +95,8 @@ BEGIN
9595
SET @HasMasked = 1;
9696
END;
9797

98-
-- If no @objname given, give a little info about all objects.
99-
IF (@objname IS NULL)
98+
-- If no @ObjectName given, give a little info about all objects.
99+
IF (@ObjectName IS NULL)
100100
BEGIN;
101101
SET @SQLString = N'SELECT
102102
[Name] = [o].[name],
@@ -107,15 +107,15 @@ BEGIN
107107
[ExtendedProperty] = [ep].[value]
108108
FROM [sys].[all_objects] [o]
109109
LEFT JOIN [sys].[extended_properties] [ep] ON [ep].[major_id] = [o].[object_id]
110-
and [ep].[name] = @epname
110+
and [ep].[name] = @ExtendedPropertyName
111111
AND [ep].[minor_id] = 0
112112
AND [ep].[class] = 1
113113
ORDER BY [Owner] ASC, [Object_type] DESC, [name] ASC;';
114-
SET @ParmDefinition = N'@epname SYSNAME';
114+
SET @ParmDefinition = N'@ExtendedPropertyName SYSNAME';
115115

116116
EXEC sp_executesql @SQLString
117117
,@ParmDefinition
118-
,@epname;
118+
,@ExtendedPropertyName;
119119

120120
-- Display all user types
121121
SET @SQLString = N'SELECT
@@ -142,49 +142,49 @@ BEGIN
142142
RETURN(0);
143143
END -- End all Sysobjects
144144

145-
-- Make sure the @objname is local to the current database.
146-
SELECT @ObjShortName = PARSENAME(@objname,1);
147-
SELECT @DbName = PARSENAME(@objname,3);
145+
-- Make sure the @ObjectName is local to the current database.
146+
SELECT @ObjShortName = PARSENAME(@ObjectName,1);
147+
SELECT @DbName = PARSENAME(@ObjectName,3);
148148
IF @DbName IS NULL
149149
SELECT @DbName = DB_NAME();
150150
ELSE IF @DbName <> DB_NAME()
151151
BEGIN
152152
RAISERROR(15250,-1,-1);
153153
END
154154

155-
-- @objname must be either sysobjects or systypes: first look in sysobjects
155+
-- @ObjectName must be either sysobjects or systypes: first look in sysobjects
156156
SET @SQLString = N'SELECT @ObjID = object_id
157157
, @SysObj_Type = type
158158
FROM sys.all_objects
159-
WHERE object_id = OBJECT_ID(@objname);';
160-
SET @ParmDefinition = N'@objname SYSNAME
159+
WHERE object_id = OBJECT_ID(@ObjectName);';
160+
SET @ParmDefinition = N'@ObjectName SYSNAME
161161
,@ObjID INT OUTPUT
162162
,@SysObj_Type VARCHAR(5) OUTPUT';
163163

164164
EXEC sp_executesql @SQLString
165165
,@ParmDefinition
166-
,@objName
166+
,@ObjectName
167167
,@ObjID OUTPUT
168168
,@SysObj_Type OUTPUT;
169169

170-
-- If @objname not in sysobjects, try systypes
170+
-- If @ObjectName not in sysobjects, try systypes
171171
IF @ObjID IS NULL
172172
BEGIN
173173
SET @SQLSTring = N'SELECT @ObjID = user_type_id
174174
FROM sys.types
175-
WHERE name = PARSENAME(@objname,1);';
176-
SET @ParmDefinition = N'@objname SYSNAME
175+
WHERE name = PARSENAME(@ObjectName,1);';
176+
SET @ParmDefinition = N'@ObjectName SYSNAME
177177
,@ObjID INT OUTPUT';
178178

179179
EXEC sp_executesql @SQLString
180180
,@ParmDefinition
181-
,@objName
181+
,@ObjectName
182182
,@ObjID OUTPUT;
183183

184184
-- If not in systypes, return
185185
IF @ObjID IS NULL
186186
BEGIN
187-
RAISERROR(15009,-1,-1,@objname,@DbName);
187+
RAISERROR(15009,-1,-1,@ObjectName,@DbName);
188188
END
189189

190190
-- Data Type help (prec/scale only valid for numerics)
@@ -201,19 +201,19 @@ BEGIN
201201
[ExtendedProperty] = ep.[value]
202202
FROM [sys].[types] AS [t]
203203
LEFT JOIN [sys].[extended_properties] AS [ep] ON [ep].[major_id] = [t].[user_type_id]
204-
AND [ep].[name] = @epname
204+
AND [ep].[name] = @ExtendedPropertyName
205205
AND [ep].[minor_id] = 0
206206
AND [ep].[class] = 6
207207
WHERE [user_type_id] = @ObjID';
208-
SET @ParmDefinition = N'@ObjID INT, @Yes VARCHAR(5), @No VARCHAR(5), @None VARCHAR(5), @epname SYSNAME';
208+
SET @ParmDefinition = N'@ObjID INT, @Yes VARCHAR(5), @No VARCHAR(5), @None VARCHAR(5), @ExtendedPropertyName SYSNAME';
209209

210210
EXECUTE sp_executesql @SQLString
211211
,@ParmDefinition
212212
,@ObjID
213213
,@Yes
214214
,@No
215215
,@None
216-
,@epname;
216+
,@ExtendedPropertyName;
217217

218218
RETURN(0);
219219
END --Systypes
@@ -228,17 +228,17 @@ BEGIN
228228
[ExtendedProperty] = [ep].[value]
229229
FROM [sys].[all_objects] [o]
230230
LEFT JOIN [sys].[extended_properties] [ep] ON [ep].[major_id] = [o].[object_id]
231-
AND [ep].[name] = @epname
231+
AND [ep].[name] = @ExtendedPropertyName
232232
AND [ep].[minor_id] = 0
233233
AND [ep].[class] = 1
234234
WHERE [o].[object_id] = @ObjID;';
235235

236-
SET @ParmDefinition = N'@ObjID INT, @epname SYSNAME';
236+
SET @ParmDefinition = N'@ObjID INT, @ExtendedPropertyName SYSNAME';
237237

238238
EXEC sp_executesql @SQLString
239239
,@ParmDefinition
240240
,@ObjID
241-
,@epname;
241+
,@ExtendedPropertyName;
242242

243243
-- Display column metadata if table / view
244244
SET @SQLString = N'
@@ -296,12 +296,12 @@ BEGIN
296296
INNER JOIN [sys].[types] AS [typ] ON [typ].[system_type_id] = [ac].[system_type_id]
297297
LEFT JOIN sys.extended_properties ep ON ep.minor_id = ac.column_id
298298
AND ep.major_id = ac.[object_id]
299-
AND ep.[name] = @epname
299+
AND ep.[name] = @ExtendedPropertyName
300300
AND ep.class = 1
301301
WHERE [object_id] = @ObjID
302302
END';
303-
SET @ParmDefinition = N'@ObjID INT, @epname SYSNAME';
304-
EXEC sp_executesql @SQLString, @ParmDefinition, @ObjID = @ObjID, @epname = @epname;
303+
SET @ParmDefinition = N'@ObjID INT, @ExtendedPropertyName SYSNAME';
304+
EXEC sp_executesql @SQLString, @ParmDefinition, @ObjID = @ObjID, @ExtendedPropertyName = @ExtendedPropertyName;
305305

306306
-- Identity & rowguid columns
307307
IF @SysObj_Type IN ('S ','U ','V ','TF')
@@ -321,13 +321,13 @@ BEGIN
321321
IF (@colname IS NOT NULL)
322322
SELECT
323323
'Identity' = @colname,
324-
'Seed' = IDENT_SEED(@objname),
325-
'Increment' = IDENT_INCR(@objname),
324+
'Seed' = IDENT_SEED(@ObjectName),
325+
'Increment' = IDENT_INCR(@ObjectName),
326326
'Not For Replication' = COLUMNPROPERTY(@ObjID, @colname, 'IsIDNotForRepl');
327327
ELSE
328328
BEGIN
329329
SET @Msg = 'No identity is defined on object %ls.';
330-
RAISERROR(@Msg, 10, 1, @objname) WITH NOWAIT;
330+
RAISERROR(@Msg, 10, 1, @ObjectName) WITH NOWAIT;
331331
END
332332

333333
-- Rowguid
@@ -347,7 +347,7 @@ BEGIN
347347
ELSE
348348
BEGIN
349349
SET @Msg = 'No rowguid is defined on object %ls.';
350-
RAISERROR(@Msg, 10, 1, @objname) WITH NOWAIT;
350+
RAISERROR(@Msg, 10, 1, @ObjectName) WITH NOWAIT;
351351
END
352352
END
353353

@@ -386,8 +386,8 @@ BEGIN
386386
IF @SysObj_Type IN ('S ','U ')
387387
BEGIN
388388
EXEC sys.sp_objectfilegroup @ObjID;
389-
EXEC sys.sp_helpindex @objname;
390-
EXEC sys.sp_helpconstraint @objname,'nomsg';
389+
EXEC sys.sp_helpindex @ObjectName;
390+
EXEC sys.sp_helpconstraint @ObjectName,'nomsg';
391391

392392
SET @SQLString = N'SELECT @HasDepen = COUNT(*)
393393
FROM sys.objects obj, sysdepends deps
@@ -404,7 +404,7 @@ BEGIN
404404

405405
IF @HasDepen = 0
406406
BEGIN
407-
RAISERROR(15647,-1,-1,@objname); -- No views with schemabinding for reference table '%ls'.
407+
RAISERROR(15647,-1,-1,@ObjectName); -- No views with schemabinding for reference table '%ls'.
408408
END
409409
ELSE
410410
BEGIN

0 commit comments

Comments
 (0)