DBAction
The table below lists more than 90 T-SQL utility routines. All of them were professionally designed, written, and tested. Collectively they are known as DBAction. DBAction consists of more than 20,000 lines (over 550 KB) of T-SQL code. All of it is original work by Wingenious.
These T-SQL routines are not like the short/simple scripts that can be downloaded from many SQL Server web sites. Those scripts have their purpose, but they do not compare to the functionality of DBAction. The free short/simple scripts are usually very specific to the author's environment, and there are hundreds of authors and hundreds of styles. The DBAction routines are an organized suite of tools with a consistent style. Many of them can be used with any database, and some rely upon a common database architecture that uses surrogate primary keys. The DBAction routines provide most of the functionality of several commercial SQL Server utility products and they put the power into a unique form (T-SQL code).
The DBAction routines include many ways to examine schema information, and some of the ways are quite unique. There are routines to generate script for standard stored procedures and other objects. There are routines to implement auditing, including restoration of data. There are routines to examine (and fix) object dependencies. The DBAction routines include several methods to import/export data from/to files. There are routines to compare or copy data between databases. There are routines to copy a branch of a database tree while retaining the original identity values or generating new identity values that are propagated to child records. The power and versatility of the DBAction routines is awesome!
Several of the DBAction routines are available as part of the published articles by Brian Walker.

DBAction routines...
Routine Description
CheckJobs Returns selected lines of run history information for each SQL Agent job.
CheckJob2 Returns many details about selected SQL Agent jobs, including their current status.
WriteLine Writes a line into a text file. Handy for logging.
ListUsers Returns the currently connected SQL Server users and their context information. Can optionally send a message to connected users.
ListFiles Returns all (or selected) files or folders from a specified directory.
ListFacts Returns many technical details about the space allocation for selected tables.
ListItems Returns a list of the objects in the database or a selected subset of them.
GetTables Returns the tables in the database (or a selected subset) with the hierarchy indicated by a number (0-N).
GetFields Returns the fields in the database (or a selected subset) with definition details.
GetValues Returns a count and percentage of distinct values for a field. Handy for evaluating selectivity for a potential index.
GetRanges Returns the values found in a numeric field (or the gaps) in the form of ranges.
GetPowers Returns the explicit user permissions for objects in the database.
GetCounts Returns informational numbers for selected tables, including row count and IDENTITY details.
GetLeaves Returns information about the child tables and records for a selected parent record.
GetTable2 Returns a list of indexes, unique constraints, check constraints, and triggers for selected tables.
GetField2 Returns field or parameter information for views, stored procedures, or user-defined functions.
GetCount2 Returns information about SQL code for views, stored procedures, user-defined functions, and triggers.
FindNames Finds fields by name in all tables and returns details about them.
BuildKeys Returns information about parent relationships, child relationships, and primary keys for selected tables.
CheckBase Compares table and field definition details between databases. Handy for finding any differences.
CheckBody Compares indexes, unique constraints, check constraints, and triggers between databases. Handy for finding any differences.
CheckMode Compares explicit user permissions between databases. Handy for finding any differences.
CheckCode Compares SQL code for views, stored procedures, user-defined functions, and triggers between databases. Handy for finding any differences.
FixLeaves Changes foreign keys in child table records from one parent table record to another.
FixTables Performs a specified operation for selected tables (default is to update statistics and recompile). Handy for repetitive operations on any/all tables.
FixThings Performs a specified operation for selected objects (default is to change object owner to dbo). Handy for repetitive operations on any/all objects.
SetStatus Enables/disables constraints and/or triggers for selected tables.
TrimPKeys Deletes the standard primary key constraints for selected tables.
GrowPKeys Creates the standard primary key constraints for selected tables (refer to Database Architecture e-book).
TrimFKeys Deletes the standard foreign key constraints for selected tables.
GrowFKeys Creates the standard foreign key constraints for selected tables (refer to Database Architecture e-book).
TrimIndex Deletes the standard foreign key indexes for selected tables.
GrowIndex Creates the standard foreign key indexes for selected tables (refer to Database Architecture e-book).
GetBranch Lists the tables in a branch of the database tree, including a count for each table of the records that are part of the branch.
SetBranch Copies a branch of the database tree, generating new primary keys and propagating them to new child records automatically. What else does this?
PutBranch Copies a branch of the database tree, keeping existing primary keys.
FixBranch Refreshes a branch of the database tree, creating missing records and/or updating existing records.
CutBranch Deletes a branch of the database tree. A branch is a record (or a set of records) in one table and all records in all tables that descend from there.
FindWords Searches for specified text in all character fields of selected tables. Returns table, field, and row count.
MendLinks Restores the system table records that track dependencies between database objects.
ShowLinks Returns the dependencies between selected objects as recorded in the system tables.
FindLinks Finds object references (or any other text) in SQL routines, separate from the system dependency records.
CloneCode Copies selected views, stored procedures, user-defined functions, and triggers to another database.
SaveTrail Activates auditing for a table with many flexible options. Auditing efficiently retains a complete history for each record.
ResetWork Disables auditing for a table either temporarily or permanently.
FetchWork Returns selected audit records for a table.
EraseWork Deletes selected audit records for a table.
GraftWork Restores selected audit records back into the original table.
SeedAutos Resets the next available IDENTITY values for selected tables.
PackAutos Removes the gaps in IDENTITY values for a table and adjusts foreign key references in child tables.
FindMatch Finds duplicate records in a table based on specified fields.
ReadBatch Reads a batch file and executes the T-SQL statements in it without using osql or xp_cmdshell.
SendBatch Executes a T-SQL batch and sends the results to a file using a different method than other routines.
SendField Calls SaveField (see below) through SendBatch. Provides an alternate method of creating a file.
SendFixed Calls SaveFixed (see below) through SendBatch. Provides an alternate method of creating a file.
SendMixed Calls SaveMixed (see below) through SendBatch. Provides an alternate method of creating a file.
SaveField Saves a single field (or an expression) from a table or view into a text file.
SaveFixed Saves the results of a query into a fixed-length field text file.
SaveMixed Saves selected records from a table or query into a comma-delimited (CSV) file.
SaveBatch Saves selected records from selected tables into a batch file. The data for each field is embedded in an INSERT statement for each record.
SaveFiles Saves selected tables into binary files in native SQL Server format.
ReadFiles Loads selected tables from binary files in native SQL Server format.
CheckFile Compares data in a table with a binary file in native SQL Server format (see SaveFiles).
CheckData Compares data in a table with data in a corresponding table in another database.
GraftFile Synchronizes data in a table with a binary file in native SQL Server format (see SaveFiles).
GraftData Synchronizes data in a table with data in a corresponding table in another database.
GraftArea Generates script to synchronize data in selected tables with data in corresponding tables in another database. Handy for refreshing foundation data.
EraseArea Generates script to truncate selected tables, including dropping and adding foreign key constraints as necessary.
CloneArea Generates script to load data into selected tables from corresponding tables in another database. Handy for copying selected tables.
MakeBatch Generates script to copy selected tables, their supporting objects, and their data.
MakeQuery Generates script to query a table. Can optionally include JOIN to related tables. Can optionally include script for additional code structures.
CreateTCI Generates script for standard trigger for selected tables (INSERT).
CreateTCU Generates script for standard trigger for selected tables (UPDATE).
CreatePCI Generates script for standard stored procedure for selected tables (INSERT).
CreatePCU Generates script for standard stored procedure for selected tables (UPDATE).
CreatePCD Generates script for standard stored procedure for selected tables (DELETE).
CreatePCS Generates script for standard stored procedure for selected tables (SELECT).
CreatePKD Generates script for standard stored procedure for selected tables (foreign key DELETE).
CreatePKS Generates script for standard stored procedure for selected tables (foreign key SELECT).
CreateFKS Generates script for standard user-defined function for selected tables.
CreateVOS Generates script for standard view for selected tables.
CreateAll Generates script to create specified standard objects for selected tables (refer to Database Architecture e-book).
DeleteAll Generates script to delete all standard objects for selected tables.
ReviewAll Returns a summarization of standard objects for selected tables.
CloneMode Generates script for explicit user permissions.
GetSource Generates script for custom routines in dependency order. Handy for archiving and/or deployment.
GetSchema Generates script for database schema. Can optionally add standard keys. Can optionally add selected standard fields. Can optionally add field name prefixes.
SavePages Generates HTML pages showing database schema details. Handy for browsing by developers and others.
DoSummary Returns the results of a crosstab query, much like the feature of Microsoft Access. Can optionally specify column headings and optionally include line totals.
FetchPage Returns a page of records (rows X-Y) from a table or query.
FetchTome Returns a related group of subsets of tables. Handy for filling an ADO.NET DataSet with just a single call to the database.