SQL Server 7.0 Useful Undocumented Stored Procedures | Database Journal

SQL Server 7.0 Useful Undocumented Stored Procedures

Apr 3, 2001
4 minute read



Introduction


In this article, I want to tell you about some useful undocumented
stored procedures shipped with SQL Server 7.0.



__ATLAS_TABLE_BLOCK__0__
This stored procedure returns the complete columns description,
including the length, type, name, and so on.
Syntax

__ATLAS_TABLE_BLOCK__1__

where
tbname       – is the table name. tbname is sysname.
table_schema – is the table schema. table_schema is sysname,
               with a default of NULL.
column_name  – is the column name. column_name is sysname,
               with a default of NULL.
This is the example:

__ATLAS_TABLE_BLOCK__2__

__ATLAS_TABLE_BLOCK__3__
This stored procedure can be used to fix a corruption in a system table
by recreate the index.
Syntax

__ATLAS_TABLE_BLOCK__4__

where
database      – is the database name. database is sysname.
systemcatalog – is the system table name. systemcatalog is sysname.
ind_id        – is the index id value. ind_id is int
Note. Before using this stored procedure the database has to be
      in single user mode.
See this link for more information:
“How can I fix a corruption in a system table?”
http://www.windows2000faq.com/Articles/Index.cfm?ArticleID=14051
This is the example:

__ATLAS_TABLE_BLOCK__5__

__ATLAS_TABLE_BLOCK__6__
This stored procedure can be used to determine whether the particular
file exists in the particular directory or not.
Syntax

__ATLAS_TABLE_BLOCK__7__

where
full_path – is the full path to the file. full_path is nvarchar(512).
filename  – is the file name. filename is nvarchar(255).
To check if file textcopy.exe exists in the C:MSSQL7BINN directory
(path by default), run:

__ATLAS_TABLE_BLOCK__8__

__ATLAS_TABLE_BLOCK__9__
Sometimes, you need to perform the same actions for all databases.
You can make cursor for this purpose, but you can also use
sp_MSforeachdb stored procedure in this case.
You can use this stored procedure to check all databases with
DBCC CHECKDB statement:

__ATLAS_TABLE_BLOCK__10__

__ATLAS_TABLE_BLOCK__11__
Sometimes, you need to perform the same actions for all tables in the
database. You can make cursor for this purpose, but you can also use
sp_MSforeachtable stored procedure in this case.
You can use this stored procedure to rebuild all indexes in your
database. Try to schedule it to execute when your server is not
very hard work.

__ATLAS_TABLE_BLOCK__12__

__ATLAS_TABLE_BLOCK__13__
This stored procedure returns the complete schema for a table, including
the length, type, name, and whether a column is computed.
Syntax

__ATLAS_TABLE_BLOCK__14__

where
tablename – is the table name. tablename is nvarchar(517).
flags     – flags is int, with a default of 0.
orderby   – orderby is nvarchar(10), with a default of NULL.
flags     – flags2 is int, with a default of 0.
To get the full columns description for the authors table in the
pubs database, run:

__ATLAS_TABLE_BLOCK__15__

__ATLAS_TABLE_BLOCK__16__
This stored procedure returns information about name, status, fill
factor, index columns names, and about used file group for the given
table.
Syntax

__ATLAS_TABLE_BLOCK__17__

where
tablename – is the table name. tablename is nvarchar(517).
indexname – is the index name. indexname is nvarchar(258).
flags     – flags is int, with a default of NULL.
To get the indexes description for the authors table in the
pubs database, run:

__ATLAS_TABLE_BLOCK__18__

__ATLAS_TABLE_BLOCK__19__
This stored procedure returns many useful information about system
data types and about user data types.
Syntax

__ATLAS_TABLE_BLOCK__20__

where
typename – is the type name. typename is nvarchar(517),
           with a default of NULL.
flags    – flags is nvarchar(10), with a default of NULL.
To get information about all built-in and user defined data types
in the pubs database, run:

__ATLAS_TABLE_BLOCK__21__

__ATLAS_TABLE_BLOCK__22__
This stored procedure returns the size in kb, which the indexes in
the particular table use.
Syntax

__ATLAS_TABLE_BLOCK__23__

where
tablename  – is the table name. tablename is nvarchar(517).
index_name – is the index name. index_name is nvarchar(258),
             with a default of NULL.
To determine the space used by the indexes from the authors table
in the pubs database, run:

__ATLAS_TABLE_BLOCK__24__

__ATLAS_TABLE_BLOCK__25__
This stored procedure sets database to suspect and let dbcc dbrepair
to kill it. You should run this sp from the context of the master
database. Use it very carefully.
Syntax

__ATLAS_TABLE_BLOCK__26__

where
dbname – is the database name. dbname is nvarchar(258).
To kill the pubs database, run:

__ATLAS_TABLE_BLOCK__27__

__ATLAS_TABLE_BLOCK__28__
This stored procedure returns the number of rows and the space
the table and index use.
Syntax

__ATLAS_TABLE_BLOCK__29__

where
name – is the table name. name is nvarchar(517).
id   – id is int, with a default of NULL.
To determine the space used by the authors table in the pubs database,
run:

__ATLAS_TABLE_BLOCK__30__

Here is the result set from my machine:

__ATLAS_TABLE_BLOCK__31__

__ATLAS_TABLE_BLOCK__32__
This stored procedure can be used to get the total size and the space
used by the tempdb database. You should execute sp_tempdbspace without
parameters.
Syntax

__ATLAS_TABLE_BLOCK__33__

This is the example:

__ATLAS_TABLE_BLOCK__34__

Here is the result set from my machine:

__ATLAS_TABLE_BLOCK__35__

__ATLAS_TABLE_BLOCK__36__
This stored procedure returns information about current SQL Server 7.0
users and processes as sp_who, but provides more detailed information.
sp_who2 returns CPUTime, DiskIO, LastBatch and ProgramName in addition
to sp_who.
Syntax

__ATLAS_TABLE_BLOCK__37__

where
loginame – the user’s login name. If not specified, the procedure
           reports on all active users of SQL Server.
This example returns information for the ‘sa’ login:

__ATLAS_TABLE_BLOCK__38__



»


See All Articles by ColumnistAlexander Chigrik

Alexander Chigrik

I am the owner of MSSQLCity.Com - a site dedicated to providing useful information for IT professionals using Microsoft SQL Server. This site contains SQL Server Articles, FAQs, Scripts, Tips and Test Exams.

Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.