I created a function called f_concat
, and I created a view called v_students
. Now I have to call the function, and with the view, execute it with a SELECT
statement. How do I do that?
PS: I do have to have a function and a view and then use a select statement to combine them.
Here is the code that I've been trying
DROP FUNCTION IF EXISTS f_concat
GO
CREATE FUNCTION f_concat
(@mike as varchar(10),
@fudge as varchar(10))
RETURNS varchar(30) AS
BEGIN
RETURN CONCAT('mike', 'fudge', '-')
END;
GO
CREATE VIEW v_students
AS
SELECT
s.student_id,
s.student_firstname + ' ' + s.student_lastname AS student_name,
s.student_gpa, m.major_name
FROM
students s
JOIN
majors m ON s.student_major_id = m.major_id
GO
EXEC f_concat @student_name= f_concat
SELECT * FROM v_students
1条答案
按热度按时间a64a0gku1#
in your example you would call
Of yourse your view should not concatenate the names, this would do the function, of course you can use the function directly in the view, if you want that the view returns the complete name