Solved

Sp inside sp

Posted on 2004-08-16
7
418 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
Comment Utility
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
Comment Utility
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
Comment Utility
to get values in variables

Declare @InstallPath varchar(100)

Select @InstallPath = Data From #ttt


Imran
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 10

Expert Comment

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

0
 
LVL 8

Author Comment

by:SNilsson
Comment Utility

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

Expert Comment

by:paelo
Comment Utility
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
Comment Utility
thanx for the points


Imran
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

762 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

10 Experts available now in Live!

Get 1:1 Help Now