Creating Nondeterministic functions in SQL Server using RAND()

后端 未结 3 539
野趣味
野趣味 2020-12-10 15:36

After a bit of searching and reading the documentation, it\'s clear that you can write user defined functions in SQL Server that are marked as either deterministic or nondet

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-10 15:51

    Because it has side effects.

    Constructs with side effects are not allowed in a function. The side effect that it has is to change some internal state that keeps track of the last rand() value issued.

    I think you can get around it by including it in a View definition then selecting from the View.

提交回复
热议问题