SQLServer2000未公开的存储过程

本文介绍了多个 SQL Server 的系统存储过程,包括获取对象的限定名称、删除对象、获取列类型字符串等。还详细解释了如何使用这些存储过程来管理和诊断数据库,例如检查数据库中的对象所有权、重建损坏的索引等。
 
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
 
object_id      - is the object id. object_id is int.
qualified_name - is the qualified name of the object. qualified_name
                 is nvarchar(512).
 
 
 
 
This is the example to get the qualified name for the authors table from the pubs database.
 
USE pubs
GO
declare @object_id int, @qualified_name nvarchar(512)
select @object_id = object_id('authors')
EXEC sp_MSget_qualified_name @object_id, @qualified_name output
select @qualified_name
GO
 
 
 
 
Here is the result set from my machine:
 
--------------------------------------
[dbo].[authors]
 
 
 
 
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
 
object_id    - is the object id. object_id is int,
               with a default of NULL.
object_name - is the name of the object. object_name is sysname,
               with a default of NULL.
object_owner - is the object owner. object_owner is sysname,
               with a default of NULL.
 
 
 
 
This is the example of dropping the titleauthor table from the pubs database.
 
USE pubs
GO
declare @object_id int
select @object_id = object_id('titleauthor')
EXEC sp_MSdrop_object @object_id
GO
 
 
 
 
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
 
tabid      - is the table id. tabid is int.
colid      - is the column id. colid is int.
typestring - is the type string. It's output parameter.
             typestring is nvarchar(255).
 
 
 
 
This is the example to get the type string for the column number 2 in the authors table, from the pubs database.
 
USE pubs
GO
declare @tabid int, @typestring nvarchar(255)
select @tabid = object_id('authors')
EXEC sp_gettypestring @tabid, 2, @typestring output
select @typestring
GO
 
 
 
 
Here is the result set from my machine:
 
-------------------------------
varchar(40)
 
 
 
 
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
 
install_path - is the installation path. It's output parameter.
                install_path is nvarchar(260).
 
 
 
 
This is the example to get the path to the SQL Server 2000 tools and utilities.
 
USE master
GO
declare @install_path NVARCHAR(260)
EXEC sp_MSgettools_path @install_path OUTPUT
select @install_path
GO
 
 
 
 
Here is the result set from my machine:
 
------------------------------------------------------------
C:/Program Files/Microsoft SQL Server/80/Tools
 
 
 
 
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
 
uid - is the User ID, unique in this database. uid is smallint.
 
 
 
 
This is the example to get the list of the objects, owned by the database owner 1 in the pubs database.
 
USE pubs
GO
EXEC sp_MScheck_uid_owns_anything 1
GO
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
 
table_name   - is the table name. table_name 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:
 
USE pubs
GO
EXEC sp_columns_rowset 'authors'
GO
 
 
 
 
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
 
dbname - is the database name. dbname is sysname.
tabname - is the system table name. tabname is sysname.
indid   - is the index id value. indid 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?
 
This is the example:
 
USE pubs
GO
EXEC sp_fixindex pubs, sysindexes, 2
GO
 
 
 
 
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
 
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:
 
USE pubs
GO
EXEC sp_MShelpcolumns 'authors'
GO
 
 
 
 
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
 
tablename - is the table name. tablename is nvarchar(517).
indexname - is the index name. indexname is nvarchar(258),
            with a default of NULL.
flags     - flags is int, with a default of NULL.
 
 
 
 
To get the indexes description for the authors table in the pubs database, run:
 
USE pubs
GO
EXEC sp_MShelpindex 'authors'
GO
 
 
 
 
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
 
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:
 
USE pubs
GO
EXEC sp_MShelptype
GO
 
 
 
 
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
 
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:
 
USE pubs
GO
EXEC sp_MSindexspace 'authors'
GO
 
 
 
 
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
 
dbname - is the database name. dbname is nvarchar(258).
 
 
 
 
To kill the pubs database, run:
 
USE master
GO
EXEC sp_MSkilldb 'pubs'
GO
 
 
 
 
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
 
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:
 
USE pubs
GO
EXEC sp_MStablespace 'authors'
GO
 
 
 
 
Here is the result set from my machine:
 
Rows        DataSpaceUsed IndexSpaceUsed
----------- ------------- --------------
23          8             32
 
 
 
 
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
------------- ----------------------- -----------------------------
tempdb        9.750000                .562500
 
 
 
 
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
 
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:
 
EXEC sp_who2 'sa'
sp_MSgetversion
This extended stored procedure can be used to get the current version of Microsoft SQL Server. To get the current SQL Server version, run
 
EXEC master..sp_MSgetversion
 
Note. A more common way to retrieve the current SQL Server version (this way provides more information) is to use following SELECT statement:
 
SELECT @@version
 
 
xp_dirtree
This extended stored procedure can be used to get a list of all the folders for the folder named in the xp. To get a list of all the folders in the C:/MSSQL7 folder, run:
 
EXEC master..xp_dirtree 'C:/MSSQL7'
 
 
xp_enum_oledb_providers
This extended stored procedure is used to list of all the available OLE DB providers. It returns Provider Name, Parse Name and Provider Description. To get a list of all OLE DB providers for your SQL Server, run:
 
EXEC master..xp_enum_oledb_providers
 
 
xp_enumcodepages
This extended stored procedure can be used to list of all code pages, character sets and their description for your SQL Server. To get a list of all code pages and character sets, run:
 
EXEC master..xp_enumcodepages
 
 
xp_enumdsn
This extended stored procedure returns a list of all System DSNs and their description. To get the list of System DSNs, run:
 
EXEC master..xp_enumdsn
 
 
xp_enumerrorlogs
This extended stored procedure returns the list of all error logs with their last change date. To get the list of error logs, run:
 
EXEC master..xp_enumerrorlogs
 
 
xp_enumgroups
This extended stored procedure returns the list of Windows NT groups and their description. To get the list of the Windows NT groups, run:
 
EXEC master..xp_enumgroups
 
 
xp_fileexist
You can use this extended stored procedure to determine whether a particular file exists on the disk or not.
 
Syntax:
 
EXECUTE xp_fileexist filename [, file_exists INT OUTPUT]
 
For example, to check whether the file boot.ini exists on disk c: or not, run:
 
EXEC master..xp_fileexist 'c:/boot.ini'
 
 
xp_fixeddrives
This very useful extended stored procedure returns the list of all hard drives and the amount of free space in Mb for each hard drive.
 
To see the list of drives, run:
 
EXEC master..xp_fixeddrives
xp_getnetname
This extended stored procedure returns the WINS name of the SQL Server that you're connected to.
 
To view the name, run:
 
EXEC master..xp_getnetname
 
 
xp_readerrorlog
This extended stored procedure returns the content of the errorlog file. You can find the errorlog file in the C:/MSSQL7/Log directory, by default for SQL Server 7.0.
 
To see the text of the errorlog file, run:
 
EXEC master..xp_readerrorlog
 
 
xp_regdeletekey
This extended stored procedure will delete an entire key from the registry. You should use it very carefully.
 
Syntax:
 
EXECUTE xp_regdeletekey [@rootkey=]'rootkey',
                        [@key=]'key'
 
 
 
 
For example, to delete the key 'SOFTWARE/Test' from 'HKEY_LOCAL_MACHINE', run:
 
EXEC master..xp_regdeletekey
     @rootkey='HKEY_LOCAL_MACHINE', 
     @key='SOFTWARE/Test'
 
 
 
 
xp_regdeletevalue
This extended stored procedure will delete a particular value for a key in the registry. You should use it very carefully.
 
Syntax:
 
EXECUTE xp_regdeletevalue [@rootkey=]'rootkey',
                          [@key=]'key',
                          [@value_name=]'value_name'
 
 
 
 
For example, to delete the value 'TestValue' for the key 'SOFTWARE/Test' from 'HKEY_LOCAL_MACHINE', run:
 
EXEC master..xp_regdeletevalue
     @rootkey='HKEY_LOCAL_MACHINE',
     @key='SOFTWARE/Test',
     @value_name='TestValue'
 
 
 
 
xp_regread
This extended stored procedure is used to read from the registry.
 
Syntax:
 
EXECUTE xp_regread [@rootkey=]'rootkey',
                   [@key=]'key'
                   [, [@value_name=]'value_name']
                   [, [@value=]@value OUTPUT]
 
 
 
 
For example, to read into the variable @test from the value 'TestValue' from the key 'SOFTWARE/Test' from the 'HKEY_LOCAL_MACHINE', run:
 
DECLARE @test varchar(20)
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
 @key='SOFTWARE/Test',
 @value_name='TestValue',
 @value=@test OUTPUT
SELECT @test
 
xp_regwrite
This extended stored procedure is used to write to the registry.
 
Syntax:
 
EXECUTE xp_regwrite [@rootkey=]'rootkey',
                    [@key=]'key',
                    [@value_name=]'value_name',
                    [@type=]'type',
                    [@value=]'value'
 
For example, to write the variable 'Test' to the 'TestValue' value, key 'SOFTWARE/Test', 'HKEY_LOCAL_MACHINE', run:
 
EXEC master..xp_regwrite
     @rootkey='HKEY_LOCAL_MACHINE',
     @key='SOFTWARE/Test',
     @value_name='TestValue',
     @type='REG_SZ',
     @value='Test'
 
xp_subdirs
This extended stored procedure is used to get the list of folders for the folder named in the xp. In comparison with xp_dirtree, xp_subdirs returns only those directories whose depth = 1.
 
This is the example:
 
EXEC master..xp_subdirs 'C:/MSSQL7'
 
Note.Keep in mind that these undocumented extended stored procedures are not officially supported by Microsoft, and that they may not be found in the next version of SQL Server.
 
采用PyQt5框架与Python编程语言构建图书信息管理平台 本项目基于Python编程环境,结合PyQt5图形界面开发库,设计实现了一套完整的图书信息管理解决方案。该系统主要面向图书馆、书店等机构的日常运营需求,通过模块化设计实现了图书信息的标准化管理流程。 系统架构采用典型的三层设计模式,包含数据存储层、业务逻辑层和用户界面层。数据持久化方案支持SQLite轻量级数据库与MySQL企业级数据库的双重配置选项,通过统一的数据库操作接口实现数据存取隔离。在数据建模方面,设计了包含图书基本信息、读者档案、借阅记录等核心数据实体,各实体间通过主外键约束建立关联关系。 核心功能模块包含六大子系统: 1. 图书编目管理:支持国际标准书号、中国图书馆分类法等专业元数据的规范化著录,提供批量导入与单条录入两种数据采集方式 2. 库存动态监控:实时追踪在架数量、借出状态、预约队列等流通指标,设置库存预警阈值自动提醒补货 3. 读者服务管理:建立完整的读者信用评价体系,记录借阅历史与违规行为,实施差异化借阅权限管理 4. 流通业务处理:涵盖借书登记、归还处理、续借申请、逾期计算等标准业务流程,支持射频识别技术设备集成 5. 统计报表生成:按日/月/年周期自动生成流通统计、热门图书排行、读者活跃度等多维度分析图表 6. 系统维护配置:提供用户权限分级管理、数据备份恢复、操作日志审计等管理功能 在技术实现层面,界面设计遵循Material Design设计规范,采用QSS样式表实现视觉定制化。通过信号槽机制实现前后端数据双向绑定,运用多线程处理技术保障界面响应流畅度。数据验证机制包含前端格式校验与后端业务规则双重保障,关键操作均设有二次确认流程。 该系统适用于中小型图书管理场景,通过可扩展的插件架构支持功能模块的灵活组合。开发过程中特别注重代码的可维护性,采用面向对象编程范式实现高内聚低耦合的组件设计,为后续功能迭代奠定技术基础。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值