Solved

Sp inside sp

Posted on 2004-08-16
7
420 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

786 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