How to return a query from sp?I came across the situation where I have to return a query from sp and
assign that to session.This sample query.Original one is large one having inner join on many table.Table name is dynamic.There 2 query in the sp.One should execute and other can send to the C# page.How to access that query in C#.I don't want it's result.just query.I have shown only one query here that I want to return.
create Procedure Sample
declare @pid varchar(10)
declare @query varchar(500)
set @pid = cast(@id as varchar(10))
set @query ='select * from Table1 where id = '+@pid+''
--Execute sp_executesql @query