Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to prevent xp_regread error

695 views
Skip to first unread message

Richard Ding

unread,
Apr 25, 2003, 5:04:40 PM4/25/03
to
Hi all, I'm writing a stored procedure that reads and displays the registry
for processor information. This is what I have used:

DECLARE @CPUNameString varchar(100)
EXEC master..xp_regread
@rootkey='HKEY_LOCAL_MACHINE',
@key='HARDWARE\DESCRIPTION\system\Centralprocessor\0',
@value_name='ProcessorNameString',
@value = @CPUNameString OUTPUT
SELECT @CPUNameString

The problem is when some of our servers don't have the "cpunamestring" value
under the \0 key, the above query returns error:
Msg 22001, Level 1, State 22001
RegQueryValueEx() returned error 2, 'The system cannot find the file
specified.'

I seem to be unable to get rid of the error message. Anyone got an idea how
to prohibit the error message while running the store dproc?

Your advice is appreciated.


Richard


oj

unread,
Apr 25, 2003, 5:41:50 PM4/25/03
to
You know it's undocumented and unsupported, right.

Anyway, here is how you would do it.

DECLARE @CPUNameString varchar(100)
EXEC master..xp_regread
@rootkey='HKEY_LOCAL_MACHINE',
@key='HARDWARE\DESCRIPTION\system\Centralprocessor\0',
@value_name='ProcessorNameString',

@value = @CPUNameString OUTPUT,
@no_output = 'no_output'
SELECT isnull(@CPUNameString,'RegVal not found.')


--
-oj
RAC v2.1 & QALite!
http://www.rac4sql.net


"Richard Ding" <di...@cleanharbors.com> wrote in message
news:uqWzeA3C...@TK2MSFTNGP11.phx.gbl...

Richard Ding

unread,
Apr 25, 2003, 5:51:37 PM4/25/03
to
Hi oj, thanks a lot. the @no_output is really what I 'm looking for :-)

I know this is not documented or supported by MS. I've been searching google
for a while but haven't seen anyone mentioned @no_output. Do you have a
reference or a link to this one?


Richard

"oj" <nospam...@home.com> wrote in message
news:Ocdu7N3C...@TK2MSFTNGP11.phx.gbl...

oj

unread,
Apr 25, 2003, 6:36:36 PM4/25/03
to
heheheheh...wouldn't call it *undocumented* for nothing. ;)

no, i don't recall seeing any links out there for this flag. if you want to
learn of undoc stuff, you might want to start reading ALL system procs.

--
-oj
RAC v2.1 & QALite!
http://www.rac4sql.net


"Richard Ding" <di...@cleanharbors.com> wrote in message

news:u2tEaT3C...@TK2MSFTNGP10.phx.gbl...

Anith Sen

unread,
Apr 25, 2003, 6:42:40 PM4/25/03
to
Check :
http://www.sql-server-performance.com/ac_extended_stored_procedures.asp

--
- Anith
( Please reply to newsgroups only )


oj

unread,
Apr 25, 2003, 6:43:49 PM4/25/03
to
ain't find '@no_output' there but tis a good list, never-the-less. ;)

--
-oj
RAC v2.1 & QALite!
http://www.rac4sql.net


"Anith Sen" <an...@bizdatasolutions.com> wrote in message
news:ehIGlu3C...@TK2MSFTNGP10.phx.gbl...

Richard Ding

unread,
Apr 25, 2003, 6:44:01 PM4/25/03
to
Thanks.

"Anith Sen" <an...@bizdatasolutions.com> wrote in message
news:ehIGlu3C...@TK2MSFTNGP10.phx.gbl...

0 new messages