Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to access the columns from Stored Procedure

Author  Topic 

nayanancha
Starting Member

27 Posts

Posted - 2012-03-14 : 13:44:37
I have a sp which returns 2 columns. I need to access these two columns

If it was a table valued function I would have get those like below


Declare @UserPrefix varchar(10), @companyId int
Select @UserPrefix=UserPrefix, @CompanyId=CompanyId
from dbo.fn_GetUserPrefixCompanyId (@PDBPath, @CompanyCode)
select @UserPrefix, @companyId


But for stored Procedure how can get these two columns.

Thanks,

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-03-14 : 13:51:11
Put the result set into a temp table:

create table #temp ...

insert into #temp ...
exec someProc ...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

nayanancha
Starting Member

27 Posts

Posted - 2012-03-14 : 14:04:13
thanks it works
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-03-14 : 14:26:07
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -