Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear All,

Is there a way through which i can get selective columns returned by a SP.

e.g.
SQL
create procedure sample_sp
as
begin
    select 1 col1, 2 col2, 3 col3
end



Now when i execute it in the backend, i want only col2 and col3
EXEC sample_sp



Is this possible by any means ????
I can not use function instead of SP.

Regards,
Gopal
Posted
Comments
Zoltán Zörgő 1-Feb-13 3:01am    
What do you want exactly? Please improve your question, since how I have understood, it is the most basic of all tasks - but I suppose you wouldn't ask in that case. So might happen that I have not understood you. What do you mean by "selective columns"?

1 solution

Just make changes in the sp

SQL
create procedure sample_sp
as
begin
    select  2 col2, 3 col3
end
 
Share this answer
 
Comments
gopalgupta 1-Feb-13 4:20am    
cant do this. my sp returns 10 columns and its been used at several places. i store the output of this sp by making a temp table and then insert the outout of this sp into that table. the problem is everytime i increase the number of columns returned by the sp, i have to make changes at all other places where this sp is referred
Santhosh Kumar Jayaraman 1-Feb-13 4:25am    
it doesnt matter right? Wherever you are going to bind this datatable to a control, just filter only columns2 and columns3.If its a gridview, just bind the columns to those 2 columns
gopalgupta 1-Feb-13 6:33am    
i m not using the output in the front end. it is completely back end related.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900