Skip to content
Merle edited this page Jan 24, 2023 · 11 revisions

Welcome to the TSQLExamples wiki!

Create TSQLExampleDatabase.sql

This optional script creates the TSQLExample database with no optional arguments. It also creates three tables, TableA, TableB, TableC and inserts a handful of records in each.

Example-ApproximateRowCountsLargeTables.sql

This script provides approximate row counts using sys.objects, sys.indexes and dm_db_partition stats. This script should be used on large databases when an exact row count is not needed.

Example-SchemaSizesInADatabase.sql

This script returns the size of each schema of a database in megabytes.

Example-UnionQuerySum.sql

This script sums the result of a union query.

Example-UpdateOneTableFromAnother.sql

Example-TableSizeQueryWithStartDate.sql

This script returns a list of table names with create date, schema name, row counts, used size in megabytes and total size in megabytes.

Example-ConvertDateTimeToISO8601Format.sql

This script coverts a standard SQL datetime column to ISO 8601 format.

Example-GenerateRandomDates.sql

This script returns a pseudo random date in a range using datediff, dateadd and rand()

Example-GenerateRandomDollarAmounts.sql

This script returns pseudo random dollar amounts between a user specified limit.

Example-GeocodeDecimalLatitudeLongitude.sql

This script geocodes a point stored in decimal format.