Transact-SQL
Hi
It can be possible using OPENROWSET() See Help..giving sample...but check whether syntax is ok.
SELECT * FROM OPENROWSET('SQLOLEDB','server=name';trusted_connection=yes;'exec procedue parematers')
For that U have to make activation of Ad hoc queries in SQL 2005.
You can't direclty fetch the result from the SP..
But there is few work around available.. the OPENROWSET is one of the workaround, but you can cosider the following approach too..
1. Geting the SP result in Tables
Create Table #Temp (SomeColumn Definition)
Insert INTO #Temp Exec spName @Params
Select * From #TEMP
2. Convert your SP logic into Function .. (RECOMMENDED)
Create Function db.FetchData(@UserID)
Returns @ResultTable Table (SomeColumn Definitions..) as
Begin
Insert Into @Resulttable
Select .... Where UserID = @UserId;
Return;
End
go
Select * From FetchData(100);