SQL Server's extended stored procedures (several useful summary of procedure)

Source: Internet
Author: User

In SQL Server, there are not many opportunities to extend the storage process for direct use.
I have summarized several useful extended stored procedures as follows:

-- Obtain the version number of MS SQL
Execute master .. sp_msgetversion
Go
-- The effect is as follows:
Character_value
------------------------------------------
8.00.760 1 3

(The number of affected rows is 1)

-- Obtain the hard disk file information
-- Parameter description: directory name, directory depth, and whether to display files
Execute master .. xp_dirtree 'C :'
Go
Execute master .. xp_dirtree 'C: ', 1
Go
Execute master .. xp_dirtree 'C: ', 1, 1
Go

-- List all provided by oledb installed on the serverProgram
Execute master .. xp_enum_oledb_providers
Go

-- List all installed on the serverCodePage
Execute master .. xp_enumcodepages
Go

-- List the DSN configured on the server
Execute master .. xp_enumdsn
Go

-- List the SQL server error logs and the last update time
Execute master .. xp_enumerrorlogs
Go

 

-- List all Windows Local Groups on the server
Execute master .. xp_enumgroups
Go

-- Check file existence
Execute master .. xp_fileexist 'C: \ A. Bak'
Go

Declare @ flag int
Exec master.. xp_fileexist 'C: \ ABC. Bak', @ flag out
If @ flag = 1
Begin
Print 'exist'
End
Else
Begin
Print 'no exist'
End
Go

-- List the fixed drives on the server and the available space for each drive
Execute master .. xp_fixeddrives
Go

-- Obtain the computer name of the current SQL Server server.
Execute master .. xp_getnetname
Go

 

-- List the specific content of the current Error Log
Exec [Master]. [DBO]. [xp_readerrorlog]
Go

-- List all sub-directories under a specified directory
Exec [Master]. [DBO]. [xp_subdirs] 'C: \ WINNT'
Go

--- List drive names
-- Low free space in bytes)
-- Drive type: Hard Drive (1), Hard Drive (2), CD-Rom (8)
Exec [Master]. [DBO]. [xp_availablemedia]
Go

-- The effect is as follows:
Name low free high free media type
C: \ 1270386688 0 2
D: \ 1726824448 2 2
E: \ 875053056 10 2
F: \ 0 0 8

(The number of affected rows is 4)

The [Master]. [DBO]. [sp_addlogin] contains the encryption function pwdencrypt. If you are interested, try again.

I hope the Knowledge mentioned above will prompt you.
Of course, you are welcome to contact us and correct us.

Author: aierong
Blog: http://www.cnblogs.com/aierong
Email: aierong@126.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.