Tuesday, 1 May 2018

Order by not working when insert in temp table

order by in temp table sql server not worked
Description:

In this example we explain that order by in temp table is not worked in SQL Server. Or how to create or perform order by in temp table in SQL Server. Or SQL query to perform order by in temp table in SQL Server.

There are many questions are raised from many developers like order by not working when insert in temp table so to overcome this problem we have created below query that would be helpful for all to perform order by in temp table in SQL Server.
Query:
  
SELECT *
INTO #temp
FROM @Data
ORDER BY Id DESC

SELECT *
FROM #temp
  
Above query will not perform order by Id because you have to again give order by when you select data from temp table like below query

select *
from #temp
order by Id DESC



This entry was posted in :

0 comments:

Post a Comment