sql—在insert into中使用用户定义的函数

zbwhf8kr  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(336)

我有一个标量值函数,它接受 varchar(5) 并将其转换为另一个值。我正试图用它来 INSERT INTO :

INSERT INTO AccountTable
(
    [CustomerName],
    [CurrencyAbbreviation]
)
SELECT 
    customers.CustomerAbbreviation,
    funAMSGetCurrency(customers.Currency)                           
FROM CustomerTable customers

…但是有个错误说 funAMSGetCurrency 不是内置函数。可以这样翻译吗?

j2cgzkjk

j2cgzkjk1#

要在SQLServer中调用用户定义的函数,需要包含模式,这可能是 dbo :

INSERT INTO AccountTable ([CustomerName], [CurrencyAbbreviation] )
    SELECT customers.CustomerAbbreviation,
           dbo.funAMSGetCurrency(customers.Currency)                           
    FROM CustomerTable customers ;

相关问题