I'm trying to update sum columns data like this:
我正在尝试更新sum列数据,如下所示:
update
tableName
set
score = myFunction(tableName.id)
In other hands I want to have a table like this:
在另一方面,我想要一个像这样的表:
column1 | column2
------------------------------
id1 | myFunction(id1)
id2 | myFunction(id2)
id3 | myFunction(id3)
id4 | myFunction(id4)
I defined myFunction
as a scalar-valued functions. I also tried it as a table-valued function but I see this error in SQL Server 2012:
我将myFunction定义为标量值函数。我也尝试过它作为一个表值函数,但我在SQL Server 2012中看到了这个错误:
Msg 195, Level 15, State 10, Line 14
'myFunction' is not a recognized built-in function name.Msg 195,Level 15,State 10,Line 14'myFunction'不是公认的内置函数名。
Please help me
请帮帮我
1 个解决方案
#1
3
Try using the full name of the function, including the database and schema name:
尝试使用函数的全名,包括数据库和模式名称:
update
tableName
set
score = <database>.<schema>.myFunction(tableName.id)
I think only the schema name is needed, but I've gotten in the habit of putting both.
我认为只需要模式名称,但我已经养成了将两者都放在一起的习惯。
The documentation explains that at least the two part name is needed. If you don't know what schema are, then the following will probably work:
文档说明至少需要两个部分名称。如果您不知道哪个模式,那么以下内容可能会起作用:
update
tableName
set
score = dbo.myFunction(tableName.id)
#1
3
Try using the full name of the function, including the database and schema name:
尝试使用函数的全名,包括数据库和模式名称:
update
tableName
set
score = <database>.<schema>.myFunction(tableName.id)
I think only the schema name is needed, but I've gotten in the habit of putting both.
我认为只需要模式名称,但我已经养成了将两者都放在一起的习惯。
The documentation explains that at least the two part name is needed. If you don't know what schema are, then the following will probably work:
文档说明至少需要两个部分名称。如果您不知道哪个模式,那么以下内容可能会起作用:
update
tableName
set
score = dbo.myFunction(tableName.id)