gpt4 book ai didi

sql - 找不到用户定义的函数

转载 作者:行者123 更新时间:2023-12-02 05:07:03 26 4
gpt4 key购买 nike

DECLARE @lastname VARCHAR(25)
DECLARE @birthdate VARCHAR(25)
SELECT @lastname = 'Smith'

SELECT @birthdate = '19-Apr-36'

INSERT INTO [TEST_TABLE](lastname, birthdate)
VALUES (@lastname, (dbo.scrubDateDOBString(@birthdate)))

无论如何要使前面的查询在 ssms08 中工作?

我收到以下错误:

Msg 4121, Level 16, State 1, Line 5
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.scrubDateDOBString", or the name is ambiguous.

以下作品:

INSERT INTO TEST_TABLE (lastname, birthdate) 
VALUES ('test', (dbo.scrubDateString('2/2/48')))

最佳答案

您是否尝试过使用 INSERT INTO...SELECT

DECLARE @lastname VARCHAR(25)
DECLARE @birthdate VARCHAR(25)
SET @lastname = 'Smith'
SET @birthdate = '19-Apr-36'

insert into [TEST_TABLE] (lastname,birthdate)
SELECT @lastname, dbo.scrubDateDOBString(@birthdate)

您可能需要将您的@生日 转换为不同的格式

如果你需要装箱,你可以这样做:

insert into [TEST_TABLE] (lastname,birthdate) 
SELECT @lastname, dbo.scrubDateDOBString(cast(@birthdate as datetime))

关于sql - 找不到用户定义的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9832206/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com