找不到用户定义的函数
问题描述:
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)
您可能需要投你@birthdate
以不同的格式
如果你需要区分它,你可以这样来做:
insert into [TEST_TABLE] (lastname,birthdate)
SELECT @lastname, dbo.scrubDateDOBString(cast(@birthdate as datetime))
这是否存在功能?你有执行该功能的权限吗? – 2012-03-22 23:49:47
scrubDateDOBString看起来像什么,即它返回什么?它看起来像返回一个表。 – 2012-03-22 23:53:51
返回一个日期时间,我做了一个类似的测试工作。查看OP的更新。 – Rod 2012-03-22 23:57:27