不好意思,上面把 update 写错了。 update 表名 set 字段名=自定义函数名(参数列表) where 条件
SQL codeudpate 表名set 字段名=自定义函数名(参数列表)where 条件
create function f_ch2py(@chn nchar(1)) returns char(1) as begin declare @n int declare @c char(1) set @n = 63
select @n = @n +1, @c = case chn when @chn then char(@n) else @c end from( select top 27 * from ( select chn = '吖' union all select '八' union all select '嚓' union all select '咑' union all select '妸' union all select '发' union all select '旮' union all select '铪' union all select '丌' union all select --because have no 'i' '丌' union all select '咔' union all select '垃' union all select '嘸' union all select '拏' union all select '噢' union all select '妑' union all select '七' union all select '呥' union all select '仨' union all select '他' union all select '屲' union all select --no 'u' '屲' union all select --no 'v' '屲' union all select '夕' union all select '丫' union all select '帀' union all select @chn) as a order by chn COLLATE Chinese_PRC_CI_AS ) as b return(@c) end
调用时: update LsItem set py=f_ch2py(参数列表) where itemcode='001336'我是写在提取拼音字母的函数,那么用他的时候,“参数列表”要写什么呢?
update LsItem set py=f_ch2py(PY)//PY 是这个字段的名 或update LsItem set py=f_ch2py('PY') 这两个执行以后都说:'f_ch2py' 不是可以识别的函数名。 该数据库中已经策创建了那个函数了啊!请问还会是什么问题呢?
@chn这个时候你需要让他等于啥就写啥啊
你确定数据库中有 f_ch2py 这个自定义函数吗?看一下 f_ch2py 的所有都是什么,比如是 dbo,则这样试试: update LsItem set py=dbo.f_ch2py(py) where itemcode='001336'
update 表名 set 字段名=自定义函数名(参数列表) where 条件
returns char(1)
as
begin
declare @n int
declare @c char(1)
set @n = 63
select @n = @n +1,
@c = case chn when @chn then char(@n) else @c end
from(
select top 27 * from (
select chn =
'吖' union all select
'八' union all select
'嚓' union all select
'咑' union all select
'妸' union all select
'发' union all select
'旮' union all select
'铪' union all select
'丌' union all select --because have no 'i'
'丌' union all select
'咔' union all select
'垃' union all select
'嘸' union all select
'拏' union all select
'噢' union all select
'妑' union all select
'七' union all select
'呥' union all select
'仨' union all select
'他' union all select
'屲' union all select --no 'u'
'屲' union all select --no 'v'
'屲' union all select
'夕' union all select
'丫' union all select
'帀' union all select @chn) as a
order by chn COLLATE Chinese_PRC_CI_AS
) as b
return(@c)
end
调用时:
update LsItem set py=f_ch2py(参数列表) where itemcode='001336'我是写在提取拼音字母的函数,那么用他的时候,“参数列表”要写什么呢?
或update LsItem set py=f_ch2py('PY')
这两个执行以后都说:'f_ch2py' 不是可以识别的函数名。
该数据库中已经策创建了那个函数了啊!请问还会是什么问题呢?
update LsItem set py=dbo.f_ch2py(py) where itemcode='001336'