Abderrazzak Benbouya
Abderrazzak Benbouya

Reputation: 93

How to sort table result within a function SQL SERVER?

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++

Upvotes: 0

Views: 102

Answers (1)

Juan Carlos Oropeza
Juan Carlos Oropeza

Reputation: 48177

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?

Upvotes: 2

Related Questions