Posts tagged SQL Server 2000

Table information – column lengths, counts and unique counts

1
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 [...]

Return the MAX of all dates within all tables within all databases

0
I wanted to produce a list of the MAX of date fields (DateTime, SmallDateTime, TimeStamp) for all tables within all databases held in an instance of SQL Server. The script below was written for SQL Server 2000, but should be easily customisable for SQL Server 2005 As always, please ensure you test [...]

Detach, Move, and re-Attach database

0
The Transact-SQL Script below, is useful if you want to standardise the location of your databases. I have been managing a server whereby databases created by other people were created all over the place!! Therefore, this script was written to make life so much easier. Be sure to read through [...]

Maintenance Plan Error “Server: Msg 22029, Level 16, State 1, Line 0 sqlmaint.exe failed.”

1
Earlier today, I discovered that the database maintenance plan on one of our SQL Server machine wasn’t working. When I reviewed the logs, it simply said “sqlmaint.exe failed”. I ran the following command (copied from the SQL Server Agent job) using Query Analyzer (as this was a SQL Server 2000 [...]

Count the number of records in each table within a database

0
The Transact-SQL script below (written for SQL Server 2000, but also works with 2005), returns a list of tables and a count of the number of records within each table. USE [database name] GO DECLARE @name VARCHAR(500) DECLARE @sql VARCHAR(1000) CREATE TABLE #TableRecordCount ( TableName [...]

List of database tables, with count of records.

0
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 [...]
Go to Top