Solved

Sp inside sp

Posted on 2004-08-16
7
419 Views
Last Modified: 2012-08-14
This is working in EM:
EXEC Master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Setup', 'SQLPath'

How can I implement that in a stored procedure:
________________________________________
Declare @InstallPath varchar(100)
SET @InstallPath = Exec Master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Setup', 'SQLPath'
________________________________________

The above is throwing an error, and beside it return 2 column I only want the 'Data' col that have the path.

Help with syntax or workaround please !
0
Comment
Question by:SNilsson
  • 4
  • 2
7 Comments
 
LVL 10

Accepted Solution

by:
imrancs earned 400 total points
ID: 11809831
create table #ttt (value varchar(100), data varchar(1000))
insert #ttt EXEC Master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Setup', 'SQLPath'
select * From #ttt


Imran
0
 
LVL 9

Expert Comment

by:paelo
ID: 11809848
OR

DECLARE @test varchar(20)
EXEC master..xp_regread
     @rootkey='HKEY_LOCAL_MACHINE',
     @key='SOFTWARE\Microsoft\MSSQLServer\Setup',
     @value_name='SQLPath',
     @value=@test OUTPUT
SELECT @test



-Paul.
0
 
LVL 10

Expert Comment

by:imrancs
ID: 11809855
to get values in variables

Declare @InstallPath varchar(100)

Select @InstallPath = Data From #ttt


Imran
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 10

Expert Comment

by:imrancs
ID: 11809869
Yes Paul's method is best to get the scaler values.

0
 
LVL 8

Author Comment

by:SNilsson
ID: 11809967

Your method is working fine Imran, however Paul's returned NULL.
0
 
LVL 9

Expert Comment

by:paelo
ID: 11810012
Size problem, sorry.

Change that to DECLARE @test (or @InstallPath) varchar(200) or something larger and it should be fine.


-Paul.
0
 
LVL 10

Expert Comment

by:imrancs
ID: 11810017
thanx for the points


Imran
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now