Posts tagged Database Tables
Table information – column lengths, counts and unique counts
12 months ago
in Transact-SQL
Hi.
The Transact-SQL script below returns the following information:
ID – Just an identity column used within the script
SchemaName – The name of the schema
TableName – Obviously, the name of the table
ColumnName
Type – The data type of the column
Length – The maximum number of bytes used by the [...]
Finding table column names with a specific word
01 year ago
in Transact-SQL
The code below can be used to find all tables that contain columns that have “ADDRESS” in the name. It can easily be modified to search for table column names with any specific word.
SELECT
CASE O.xtype WHEN 'U' THEN 'Table' WHEN 'V' THEN 'View' END AS Type,
O.name AS TableName,
[...]
Count of values within every field in a table
02 years ago
in Transact-SQL
The Transact-SQL script below (written for SQL Server 2005), returns a list of the values and a count for each and every field within a table. You just need to change the schema name and table name, and specify a limit (if needed) for the number of values returned for each field.
For [...]
List of database tables, with count of records.
03 years ago
in General
Use the script below, to return a list of database tables (the schema and table name) along with a count of the records within each table. This can come in useful if you are trying to compare databases.
DECLARE @TableName VARCHAR(100)
DECLARE @Schema VARCHAR(100)
DECLARE @SQL VARCHAR(1000)
DECLARE [...]