Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

When I run the below code it runs successfully. drop function udffullname go cre

ID: 3728920 • Letter: W

Question

When I run the below code it runs successfully. drop function udffullname go create function dbo.udffullname(@studentid int) returns int as begin return (select concat(lastname, ',',firstname) as Lastandfirst from student) end but when i got to test it I get the below error message. Can you let me know why? I am not sure what is wrong with my code that it will not select my attributes from my code. select studentid,firstname,lastname, [dbo].[udffullname].[studentid] from student join dbo.udffullname(12) as functionfullname on student.studentid = dbo.functionfullname.studentid; Msg 208, Level 16, State 3, Line 16 Invalid object name 'dbo.udffullname'.

Explanation / Answer

You need to remove the schema name "dbo" while defining your function udffullname.

So the correct function definition would be:

create function udffullname(@studentid int)

returns int as

begin

return (select concat(lastname, ',',firstname) as Lastandfirst from student)

end

And the select query would be:

select studentid, firstname, lastname from

student join dbo.udffullname(12) as functionfullname

on student.studentid = functionfullname.studentid;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote