?
Solved

How can i stored procedure in openrowset?

Posted on 2003-02-25
6
Medium Priority
?
411 Views
Last Modified: 2008-02-01
How can i run following tsql?


USE master
GO
SELECT a.*
FROM OPENROWSET('SQLOLEDB','servename';'sa';'password',
    'EXEC master.dbo.xp_fixeddrives') AS a
GO
0
Comment
Question by:Bharat Guru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 23

Expert Comment

by:adathelad
ID: 8017334
I don't think you can call extended stored procedures using OPENROWSET. Try using linked servers:

To add a linked server:
EXECUTE sp_addlinkedserver 'servername', N'SQL Server'

To define the login to use on this linked server:
EXECUTE sp_addlinkedsrvlogin 'servername', 'false',           'localusername', 'linkedserverusername', 'linkedserverpassword'

Then you can run the query as:
EXECUTE servername.master.dbo.xp_fixeddrives
0
 
LVL 43

Expert Comment

by:Eugene Z
ID: 8017671
You wrote:
>How can i run following tsql?

Answer: Successfully - for example from QA
0
 

Author Comment

by:Bharat Guru
ID: 8017760
when i run above sql some how i'm geting error and i don't want to create a linkserver.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 23

Expert Comment

by:adathelad
ID: 8017806
I think the error is because you're trying to call an extended stored procedure. It would work if you were calling a standard stored procedure.
0
 
LVL 23

Accepted Solution

by:
adathelad earned 80 total points
ID: 8017850
This works:

EXECUTE OPENDATASOURCE('SQLOLEDB', 'Data Source=ServerName;User ID=UserName;Password=Password'
         ).master.dbo.xp_fixeddrives
0
 

Author Comment

by:Bharat Guru
ID: 8017901
Excellent thanks a lot, Thats work perfectly
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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 shrink a transaction log file down to a reasonable size.

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