I'm trying to learn function in SQL Server, and I don't know why I cannot get a proper result from a T-SQL function.
The query what creates function is:
CREATE FUNCTION yuri_func1
(@valDate VARCHAR(10))
RETURNS VARCHAR
AS
BEGIN
DECLARE @valWeekday VARCHAR(10);
SET @valWeekday = DATENAME(WEEKDAY, @valDate);
RETURN @valWeekday;
END
And the other query is
select dbo.yuri_func1('2017-12-29') as [요일]
but the only result I got is just
Blank. (="")
But when I executed function like this,
select DATENAME(WEEKDAY, '2017-12-29')
the result was
MONDAY
I still don't get that why they return different results.
Does anybody know why?
RETURNS VARCHAR(10)