SQL Server:如何从递归函数中执行 UPDATE? [英] SQL Server: How to execute UPDATE from within recursive function?

查看:46
本文介绍了SQL Server:如何从递归函数中执行 UPDATE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个递归标量函数,需要根据它返回的值更新另一个表中的记录,但是函数中不允许使用 UPDATE 语句.

I have a recursive scalar function that needs to update a record in another table based on the value it is returning, however UPDATE statements are not allowed in the function.

如何从函数内部更新表格?

How can I update the table from within the function?

推荐答案

UPDATE 语句不允许在功能

UPDATE statements are not allowed in the function

这是规则 - 函数不允许有任何数据更改的副作用.

That's the rule - functions are not allowed to have any data-changing side-affects.

你必须使用存储过程来UPDATE.

You have to use a Stored Procedure to UPDATE.

这篇关于SQL Server:如何从递归函数中执行 UPDATE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆