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 SontakkePosted Oct 19, 2016, 4:49 AM
Nitin SontakkePosted Oct 19, 2016, 4:47 AM
Abhilash J APosted Oct 19, 2016, 3:11 AM
Nitin SontakkePosted Oct 19, 2016, 2:54 AM
Abhilash J APosted Oct 19, 2016, 1:31 AM
/*This is the passing prameter'string colname'.The parameter value will be like this: 'agencyname asc'*/
Nitin SontakkePosted Oct 18, 2016, 11:39 PM
Abhilash J APosted Oct 18, 2016, 11:14 PM
Midhun TpPosted Oct 18, 2016, 8:44 PM
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.
Abhilash J APosted Oct 18, 2016, 1:00 PM
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?
Midhun TpPosted Oct 18, 2016, 9:34 AM
Can you please post your queries. Actually why are you passing result to an table and then retrieving the same?