Fetching System setting Information from Registry : SQL Server

Pandians
Posted by Pandians under Sql Server category on | Views : 3549
As we can fetch our system setting information like Hardware , Software , Date time , Culture info setting from Control Panel --> Regional and Language Options . Here I have tried to fetch some system information using SQL Server - Extended Stored Procedure named xp_instance_regread

1. To fetch the 'Processor Information'
DECLARE @ProcesserInfo NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\CentralProcessor\0', N'ProcessorNameString', @ProcesserInfo OUTPUT
SELECT @ProcesserInfo 'Processer Info'

Processer Info
Intel(R) Core(TM)2 Duo CPU E7400 @ 2.80GHz

2. To fetch the 'Measurement System'
DECLARE @MeasurementSystem NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sCountry', @MeasurementSystem OUTPUT
SELECT @MeasurementSystem 'Measurement System'

Measurement System
United States

3. To fetch the 'List Seperator'
DECLARE @ListSeperator NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sList', @ListSeperator OUTPUT
SELECT @ListSeperator 'List Seperator'

List Seperator
,

4. To fetch the 'No of Digits after decimal'
DECLARE @DigitsafterDecimal NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'iDigits', @DigitsafterDecimal OUTPUT
SELECT @DigitsafterDecimal 'Digits after Decimal'

Digits after Decimal
2

5. To fetch the 'Digit Grouping'
DECLARE @DigitGrouping NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sNativeDigits', @DigitGrouping OUTPUT
SELECT @DigitGrouping 'Digit Grouping'

Digit Grouping
0123456789

6. To fetch the 'Negative sign symbal'
DECLARE @NegativeSignSymbol NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sNegativeSign', @NegativeSignSymbol OUTPUT
SELECT @NegativeSignSymbol 'Negative Sign Symbol'

Negative Sign Symbol
-

7. To fetch the 'Currency Symbol'
DECLARE @CurrencySymbol NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sCurrency', @CurrencySymbol OUTPUT
SELECT @CurrencySymbol 'Currency Symbol'

Currency Symbol
$

8. To fetch the 'Time Format'
DECLARE @TimeFormat NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sTimeFormat', @TimeFormat OUTPUT
SELECT @TimeFormat 'Time Format'

Time Format
h:mm:ss tt

9. To fetch the 'Time Seperator'
DECLARE @TimeSeperator NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sTime', @TimeSeperator OUTPUT
SELECT @TimeSeperator 'Time Seperator'

Time Seperator
:

10. To fetch the 'Long Date Format'
DECLARE @LongDateFormat NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sLongDate', @LongDateFormat OUTPUT
SELECT @LongDateFormat 'Long Date Format'

Long Date Format
dddd, MMMM dd, yyyy

11. To fetch the 'Short Date Format'
DECLARE @ShortDateFormat NVARCHAR(512)
EXEC master.dbo.xp_instance_regread N'HKEY_USERS', N'.DEFAULT\Control Panel\International', N'sShortDate', @ShortDateFormat OUTPUT
SELECT @ShortDateFormat 'Short Date Format'

Short Date Format
M/d/yyyy

Cheers

Comments or Responses

Login to post response