IT ppl IT ppl - 2 months ago 6
SQL Question

Insert into table from another table after sorting data of first table

I am doing something like this in SP,

insert into @FilteredTbl select * from @MasterTbl


but now problem is that i want data of @MasterTbl sorted before adding into @FilteredTbl,

How can I do that ?

Answer

Maybe something like this:

INSERT INTO @FilteredTbl 
SELECT * FROM @MasterTbl AS tbl
ORDER BY tbl.OrderbyColumn
Comments