问题描述
我有一个标量函数,它需要两个变量@ input1 @ input2,它返回@ input1和@ input2的值(实际情况比较复杂,但这会提炼出想法)。
I have a scalar function that takes a two variables @input1 @input2 and it returns the value of @input1 and @input2 (actual thing is more complex but this distills the idea).
我想使用此函数更新表列中的所有行,传递@ input1的值abc,并使用@ input2中的列名,因此我的更新语句将如下所示:
I want to update all rows in a table column using this function, passing the value 'abc ' for @input1 and using the column name in @input2, so my update statement would look something like:
update mytable set mycolumn = (select dbo.myfunc( 'abc ' , mycolumn ) )
-- prepend the literal 'abc ' to every row for column mycolumn
但这当然是不允许的。
But this is of course not allowed.
我试图根据一些字符串规则在几列上执行一些批量字符串处理。所有想法都赞赏。
I'm trying to perform some mass string handling on a couple of columns based on some string rules. All ideas appreciated.
谢谢。
推荐答案
UPDATE mytable
SET mycolumn = dbo.myfunc('abc', mycolumn)
这篇关于SQL Server 2008使用UDF更新VarChar列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!