Source: http://www.mssqlcity.com/Articles/Undoc/SQL2000UndocSP.htm
Alexander Chigrik
chigrik@mssqlcity.com
In this article, I want to tell you about some useful undocumented stored procedures shipped with SQL Server 2000.
sp_MSget_qualified_name
The sp_MSget_qualified_name stored procedure is used to get the qualified name for the given object id.Syntax
sp_MSget_qualified_name object_id, qualified_name
where |
USE pubs |
-------------------------------------- |
sp_MSdrop_object
The sp_MSdrop_object stored procedure is used to drop an object (it can be table, view, stored procedure or trigger) for the given object id, object name, and object owner. If object id, object name, and object owner are not specified, then nothing will be dropped.Syntax
sp_MSdrop_object [object_id] [,object_name] [,object_owner]
where |
USE pubs |
sp_gettypestring
The sp_gettypestring stored procedure returns the type string for the given table id and column id.Syntax
sp_gettypestring tabid, colid, typestring
where |
USE pubs |
------------------------------- |
sp_MSgettools_path
The sp_MSgettools_path stored procedure returns the path to the SQL Server 2000 tools and utilities.Syntax
sp_MSgettools_path install_path
where |
USE master |
------------------------------------------------------------ |
sp_MScheck_uid_owns_anything
The sp_MScheck_uid_owns_anything stored procedure returns the list of the object, owned by the specified user.Syntax
sp_MScheck_uid_owns_anything uid
where |
USE pubs |
sp_columns_rowset
The sp_columns_rowset stored procedure returns the complete columns description, including the length, type, name, and so on.Syntax
sp_columns_rowset table_name [, table_schema ] [, column_name]
where |
USE pubs |
sp_fixindex
The sp_fixindex stored procedure can be used to fix corruption in a system table by recreating the index.Syntax
sp_fixindex dbname, tabname, indid
where |
See this link for more information:
How can I fix a corruption in a system table?
This is the example:
USE pubs |
sp_MSforeachdb
Sometimes, you need to perform the same actions for all databases. You can create cursor for this purpose, or you can also use the sp_MSforeachdb stored procedure to accomplish the same goal with less work.For example, you can use the sp_MSforeachdb stored procedure to run a CHECKDB for all the databases on your server:
EXEC sp_MSforeachdb @command1="print '?' DBCC CHECKDB ('?')"
sp_MSforeachtable
Sometimes, you need to perform the same actions for all tables in the database. You can create cursor for this purpose, or you can also use the sp_MSforeachtable stored procedure to accomplish the same goal with less work.For example, you can use the sp_MSforeachtable stored procedure to rebuild all the indexes in a database:
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?')"
sp_MShelpcolumns
The sp_MShelpcolumns stored procedure returns the complete schema for a table, including the length, type, name, and whether a column is computed.Syntax
sp_MShelpcolumns tablename [, flags] [, orderby] [, flags2]
where |
USE pubs |
sp_MShelpindex
The sp_MShelpindex stored procedure returns information about name, status, fill factor, index columns names, and file groups for a given table.Syntax
sp_MShelpindex tablename [, indexname] [, flags]
where |
USE pubs |
sp_MShelptype
The sp_MShelptype stored procedure returns much useful information about system data types and user data types.Syntax
sp_MShelptype [typename] [, flags]
where |
USE pubs |
sp_MSindexspace
The sp_MSindexspace stored procedure returns the size in kb, of the indexes found in a particular table.Syntax
sp_MSindexspace tablename [, index_name]
where |
USE pubs |
sp_MSkilldb
The sp_MSkilldb stored procedure sets a database to suspect mode and uses DBCC DBREPAIR to kill it. You should run this sp from the context of the master database. Use it very carefully.Syntax
sp_MSkilldb dbname
where |
USE master |
sp_MStablespace
The sp_MStablespace stored procedure returns the number of rows in a table and the space the table and index use.Syntax
sp_MStablespace name [, id]
where |
USE pubs |
Rows DataSpaceUsed IndexSpaceUsed |
sp_tempdbspace
The sp_tempdbspace stored procedure can be used to get the total size and the space used by the tempdb database. It is used without parameters.Syntax
sp_tempdbspace
This is the example:
EXEC sp_tempdbspace
Here is the result set from my machine:
database_name database_size spaceused |
sp_who2
The sp_who2 stored procedure returns information about current SQL Server 2000 users and processes similar to sp_who, but it provides more detailed information. sp_who2 returns CPUTime, DiskIO, LastBatch and ProgramName in addition to the data provided by sp_who.Syntax
sp_who [loginame]
where |
EXEC sp_who2 'sa'
No comments:
Post a Comment