2

in oracle 12c it is possible to have an inline user defined function

WITH
  FUNCTION with_function(p_id IN NUMBER) RETURN NUMBER IS
  BEGIN
    RETURN p_id;
  END;
SELECT with_function(id)
FROM   t1
WHERE  rownum = 1

is there an equivalent in sql server? I have been researching for awhile but can not seem to find an equivalent.

Bryan Dellinger
  • 4,724
  • 7
  • 33
  • 79
  • 2
    There isn't really. – Radu Gheorghiu Oct 10 '18 at 13:01
  • 3
    You need to define a *bona fide* function. There are no local functions, but there are "inline" table functions that tend to be more efficient than "non-inline" table functions. – Gordon Linoff Oct 10 '18 at 13:07
  • Here is an answer which may give you what you want: https://stackoverflow.com/a/981491/9395740 – MJH Oct 10 '18 at 13:09
  • Does this answer your question? [Can I create a One-Time-Use Function in a Script or Stored Procedure?](https://stackoverflow.com/questions/981451/can-i-create-a-one-time-use-function-in-a-script-or-stored-procedure) – Mark Schultheiss Nov 26 '19 at 12:41

0 Answers0