title: How to check if the element of a particular attribute exists in a column?
body: <p>I have been given a question, where I have to Write a TSQL function that will check for the presence of department number in department table.</p>
  
  <p>Here are the records present in the DEPARTMENT table:-</p>
  
  <pre><code>DINT        DNAME                MGRSSN      MGRSTARTDATE TOTAL_SALARY
  ----------- -------------------- ----------- ------------ ------------
  1           Headquarters         888665555   1981-06-19   55000
  4           Administration       987654321   1995-01-01   98000
  5           Research             333445555   1988-05-22   136000
  </code></pre>
  
  <p>So, if I pass 1 as a parameter, it should return "YES" because DINT = 1 exists in the table and if I pass 9 as a parameter, it should return "NO".</p>
  
  <p>I don't really know how to approach this question. I tried figuring out how to use BIT in SQL SERVER but did not arrive at anything. The function should consist of one parameter, that is the DEPARTMENT NUMBER which can be denoted as DNO.</p>
  
  <p>I just want this function to return "YES" if the department number is present in the department table, else return "NO".</p>