Hello everyone,
I have a Dynamic sql query. The query executed order by passing this parameter (@SortColumn, for eg: 'agencyname asc'). And this output insert into the a table and another procedure for select all items from the table. My problem is, 1st query giving order by item but second query not giving order by items. How can I get data from second query as the order by format?


Nitin SontakkeRank #264 · 9.6K reputationPosted Oct 19, 2016, 12:49 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Oct 18, 2016, 7:39 PM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Oct 19, 2016, 12:47 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Oct 18, 2016, 5:34 AM EDT
Can you please post your queries. Actually why are you passing result to an table and then retrieving the same?
Midhun TpRank #388 · 6.5K reputationPosted Oct 18, 2016, 4:44 PM EDT
In your first procedure you are selecting rownumber in sql1. But while inserting to table, there is no column corresponding to row number in that table. Is that working fine? Please check whether there is a column mis match in insert query.
Also in your second procedure you are just using select query, so why don't you use order by clause there.
Nitin SontakkeRank #264 · 9.6K reputationPosted Oct 18, 2016, 10:54 PM EDT
Abhilash J ARank #1,243 · 1.4K reputationPosted Oct 18, 2016, 9:00 AM EDT
2nd Procedure:
In the 1st procedure there is happening Order by but not inserting items in the table order by way. How can I select orderby items?
Abhilash J ARank #1,243 · 1.4K reputationPosted Oct 18, 2016, 7:14 PM EDT
Abhilash J ARank #1,243 · 1.4K reputationPosted Oct 18, 2016, 9:31 PM EDT
/*This is the passing prameter'string colname'.The parameter value will be like this: 'agencyname asc'*/
Abhilash J ARank #1,243 · 1.4K reputationPosted Oct 18, 2016, 11:11 PM EDT