0

I want to create function that's return a sorted table based in a column value, I know that's order by doesn't work in function or view a searched her and in others website but I didn't find any things, so my idea is to use a basic ALGORITHME like in C or C++

1 Answers1

2

You cant make a function return the data in any order.

You just order the result

  SELECT  *
  FROM dbo.someFunction () 
  ORDER BY somefield

Read:

Do clustered index on a column GUARANTEES returning sorted rows according to that column How does sql server sort your data?

Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118