ImageVerifierCode 换一换
格式:DOCX , 页数:17 ,大小:18.77KB ,
资源ID:124772      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-124772.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(SQL Server 未公开的存储过程.docx)为本站会员(b****1)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

SQL Server 未公开的存储过程.docx

1、SQL Server 未公开的存储过程SQL Server 2000 未公开的存储过程sp_MSget_qualified_nameThesp_MSget_qualified_namestored procedure is used to get the qualified name for the given object id.Syntaxsp_MSget_qualified_name object_id, qualified_namewhere object_id - is the object id. object_id is int.qualified_name - is the q

2、ualified name of the object. qualified_name is nvarchar(512).This is the example to get the qualified name for theauthorstable from thepubsdatabase.USE pubsGOdeclare object_id int, qualified_name nvarchar(512)select object_id = object_id(authors)EXEC sp_MSget_qualified_name object_id, qualified_name

3、 outputselect qualified_nameGOHere is the result set from my machine:-dbo.authorssp_MSdrop_objectThesp_MSdrop_objectstored 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 o

4、bject owner are not specified, then nothing will be dropped.Syntaxsp_MSdrop_object object_id ,object_name ,object_ownerwhere 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 - i

5、s the object owner. object_owner is sysname, with a default of NULL.This is the example of dropping thetitleauthortable from thepubsdatabase.USE pubsGOdeclare object_id intselect object_id = object_id(titleauthor)EXEC sp_MSdrop_object object_idGOsp_gettypestringThesp_gettypestringstored procedure re

6、turns the type string for the given table id and column id.Syntaxsp_gettypestring tabid, colid, typestringwhere tabid - is the table id. tabid is int.colid - is the column id. colid is int.typestring - is the type string. Its output parameter. typestring is nvarchar(255).This is the example to get t

7、he type string for the column number 2 in theauthorstable, from thepubsdatabase.USE pubsGOdeclare tabid int, typestring nvarchar(255)select tabid = object_id(authors)EXEC sp_gettypestring tabid, 2, typestring outputselect typestringGOHere is the result set from my machine:-varchar(40)sp_MSgettools_p

8、athThesp_MSgettools_pathstored procedure returns the path to the SQL Server 2000 tools and utilities.Syntaxsp_MSgettools_path install_pathwhere install_path - is the installation path. Its output parameter. install_path is nvarchar(260).This is the example to get the path to the SQL Server 2000 tool

9、s and utilities.USE masterGOdeclare install_path NVARCHAR(260)EXEC sp_MSgettools_path install_path OUTPUTselect install_pathGOHere is the result set from my machine:-C:Program FilesMicrosoft SQL Server80Toolssp_MScheck_uid_owns_anythingThesp_MScheck_uid_owns_anythingstored procedure returns the list

10、 of the object, owned by the specified user.Syntaxsp_MScheck_uid_owns_anything uidwhere 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 thepubsdatabase.USE pubsGOEXEC sp_MScheck_uid_owns_anything 1GOs

11、p_columns_rowsetThesp_columns_rowsetstored procedure returns the complete columns description, including the length, type, name, and so on.Syntaxsp_columns_rowset table_name , table_schema , column_namewhere table_name - is the table name. table_name is sysname.table_schema - is the table schema. ta

12、ble_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 pubsGOEXEC sp_columns_rowset authorsGOsp_fixindexThesp_fixindexstored procedure can be used to fix corruption in a system table by recreating the ind

13、ex.Syntaxsp_fixindex dbname, tabname, indidwhere 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 intNote. Before using this stored procedure the database has to be in single user mode.See this link for mo

14、re information:How can I fix a corruption in a system table?This is the example:USE pubsGOEXEC sp_fixindex pubs, sysindexes, 2GOsp_MSforeachdbSometimes, you need to perform the same actions for all databases. You can create cursor for this purpose, or you can also use thesp_MSforeachdbstored procedu

15、re to accomplish the same goal with less work.For example, you can use thesp_MSforeachdbstored procedure to run a CHECKDB for all the databases on your server:EXEC sp_MSforeachdb command1=print ? DBCC CHECKDB (?)sp_MSforeachtableSometimes, you need to perform the same actions for all tables in the d

16、atabase. You can create cursor for this purpose, or you can also use thesp_MSforeachtablestored procedure to accomplish the same goal with less work.For example, you can use thesp_MSforeachtablestored procedure to rebuild all the indexes in a database:EXEC sp_MSforeachtable command1=print ? DBCC DBR

17、EINDEX (?)sp_MShelpcolumnsThesp_MShelpcolumnsstored procedure returns the complete schema for a table, including the length, type, name, and whether a column is computed.Syntaxsp_MShelpcolumns tablename , flags , orderby , flags2wheretablename - is the table name. tablename is nvarchar(517).flags -

18、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 theauthorstable in thepubsdatabase, run:USE pubsGOEXEC sp_MShelpcolumns authorsGOsp_MShelpindexThesp_MShelpindexstored proced

19、ure returns information about name, status, fill factor, index columns names, and file groups for a given table.Syntaxsp_MShelpindex tablename , indexname , flagswheretablename - is the table name. tablename is nvarchar(517).indexname - is the index name. indexname is nvarchar(258), with a default o

20、f NULL.flags - flags is int, with a default of NULL.To get the indexes description for theauthorstable in thepubsdatabase, run:USE pubsGOEXEC sp_MShelpindex authorsGOsp_MShelptypeThesp_MShelptypestored procedure returns much useful information about system data types and user data types.Syntaxsp_MSh

21、elptype typename , flagswheretypename - 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 thepubsdatabase, run:USE pubsGOEXEC sp_MShelptypeGOsp_MSindexspaceThe

22、sp_MSindexspacestored procedure returns the size in kb, of the indexes found in a particular table.Syntaxsp_MSindexspace tablename , index_namewheretablename - 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 determi

23、ne the space used by the indexes from theauthorstable in thepubsdatabase, run:USE pubsGOEXEC sp_MSindexspace authorsGOsp_MSkilldbThesp_MSkilldbstored procedure sets a database to suspect mode and usesDBCC DBREPAIRto kill it. You should run this sp from the context of the master database. Use it very

24、 carefully.Syntaxsp_MSkilldb dbnamewhere dbname - is the database name. dbname is nvarchar(258).To kill thepubsdatabase, run:USE masterGOEXEC sp_MSkilldb pubsGOsp_MStablespaceThesp_MStablespacestored procedure returns the number of rows in a table and the space the table and index use.Syntaxsp_MStab

25、lespace name , idwherename - is the table name. name is nvarchar(517).id - id is int, with a default of NULL.To determine the space used by theauthorstable in thepubsdatabase, run:USE pubsGOEXEC sp_MStablespace authorsGOHere is the result set from my machine:Rows DataSpaceUsed IndexSpaceUsed- - -23

26、8 32sp_tempdbspaceThesp_tempdbspacestored procedure can be used to get the total size and the space used by the tempdb database. It is used without parameters.Syntaxsp_tempdbspaceThis is the example:EXEC sp_tempdbspaceHere is the result set from my machine:database_name database_size spaceused- - -t

27、empdb 9.750000 .562500sp_who2Thesp_who2stored 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.Syntaxsp_w

28、ho loginamewhereloginame - the users 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 sasp_MSgetversionThis extended stored procedure can be used to get the current version of Microsoft SQL Server. To

29、 get the current SQL Server version, runEXEC master.sp_MSgetversionNote. A more common way to retrieve the current SQL Server version (this way provides more information) is to use following SELECT statement:SELECT versionxp_dirtreeThis 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:MSSQL7xp_enum_oledb_providersThis extended stored procedur

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2