xp_dirtree
Get a list of folders under the named folder.
EXEC master..xp_dirtree 'F:\DATA'
xp_enum_oledb_providers
List all OLE DB providers available.
EXEC master..xp_enum_oledb_providers
sp_MSgetversion
To get the current MS SQL Server version.
EXEC master..sp_MSgetversion
xp_enumcodepages
List all code pages and character sets.
EXEC master..xp_enumcodepages
xp_enumerrorlogs
Returns a list of all error logs with their last change date.
EXEC master..xp_enumerrorlogs
xp_enumdsn
List all System DSNs and their descriptions.
EXEC master..xp_enumdsn
xp_readerrorlog
Returns the contents of the error log.
EXEC master..xp_readerrorlog
xp_fixeddrives
List all hard drives and available disk space in Mb.
EXEC master..xp_fixeddrives
xp_getnetname
Get host WINS name.
EXEC master..xp_getnetname
xp_enumgroups
Return a list of NT user groups and their description.
EXEC master..xp_enumgroups
xp_fileexist
Check to see if a file exists.
EXEC master..xp_fileexist 'F:\DATA\my.log'
xp_regdeletekey
Delete a registry key.
EXEC master..xp_regdeletekey
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft'
xp_regdeletevalue
Delete a registry key value.
EXEC master..xp_regdeletevalue
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft',
@value_name='MSSQL'
xp_regread
Read a registry key.
DECLARE @test varchar(20)
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft',
@value_name='MSSQL',
@value=@test 80
SELECT @test
xp_regwrite
Write a registry key.
EXEC master..xp_regwrite
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft',
@value_name='MSSQL',
@type='REG_SZ',
@value='NEW'
To get your CD Key that you used to install SQL Server, check the following registry key using regedit:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\80\registration\CD_KEY
More often than not you may not have access to the local machine. Instead you can use xp_regread, this undocumented and not well known extended stored proceedure allows you to read contents from the Windows registry of the host. The syntax is:
EXECUTE xp_regread [@rootkey=]'rootkey',
[@key=]'key'
[, [@value_name=]'value_name']
[, [@value=]@value OUTPUT]
To view your CD Key run:
USE master
EXEC xp_regread 'HKEY_LOCAL_MACHINE',
'SOFTWARE\Microsoft\Microsoft SQL Server\80\registration',
'CD_KEY'
The SQL will return your CD install Key as a string.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jan | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
23 queries. 0.276 seconds