hi
this table unsorted. The "order by" is ignored in SQL 2012.
INSERT INTO @Customer SELECT Customer_ID, Name, CASE WHEN Expiry_Date < GETDATE() then 1 WHEN Expired = 1 then 1 ELSE 0 END from Customer **order by Name**
A table cannot be ordered during insert unless it has some primary key.
Generally records are ordered while selecting
© COPYRIGHT 2024 ASPSnippets.com ALL RIGHTS RESERVED.