Can't find a custom function
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)))
Is there anyway to get the previous request to work in ssms08?
I am getting the following error:
Msg 4121, Level 16, State 1, Line 5
Could not find column 'dbo' or UDF or collection 'dbo.scrubDateDOBString', or the name is ambiguous.
The following works:
INSERT INTO TEST_TABLE (lastname, birthdate)
VALUES ('test', (dbo.scrubDateString('2/2/48')))
+3
source to share
1 answer
Have you tried using 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)
You may need to draw your @ birthdate
in a different format
if you need to do it, you can do it like this:
insert into [TEST_TABLE] (lastname,birthdate)
SELECT @lastname, dbo.scrubDateDOBString(cast(@birthdate as datetime))
0
source to share