Solved

Sp inside sp

Posted on 2004-08-16
7
421 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
data stored like ????? in sql server column 19 53
Add a step to a system backup job 6 15
listing SQL login names of valid databases 2 20
SQL R 21 22
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

791 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