title: Why I cannot get a result value from T-SQL function
body: <p>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.</p>
  
  <p>The query what creates function is:</p>
  
  <pre><code>CREATE FUNCTION yuri_func1 
       (@valDate VARCHAR(10))
  RETURNS VARCHAR
  AS
  BEGIN
      DECLARE @valWeekday VARCHAR(10);
  
      SET @valWeekday = DATENAME(WEEKDAY, @valDate);
  
      RETURN @valWeekday;
  END
  </code></pre>
  
  <p>And the other query is </p>
  
  <pre><code>select dbo.yuri_func1('2017-12-29') as [요일]
  </code></pre>
  
  <p>but the only result I got is just </p>
  
  <blockquote>
    <p>Blank. (="")</p>
  </blockquote>
  
  <p>But when I executed function like this, </p>
  
  <pre><code>select DATENAME(WEEKDAY, '2017-12-29')
  </code></pre>
  
  <p>the result was </p>
  
  <pre><code>MONDAY
  </code></pre>
  
  <p>I still don't get that why they return different results. </p>
  
  <p>Does anybody know why?</p>