title: how to fix "Cannot find either column dbo or the user defined function or aggregate, or name is ambiguous"
body: <p>I need to call function in SQL server but got error!</p>
  
  <pre><code> cannot find either column "dbo" or the user-defined function or
      aggregate "dbo.udf_Sum_ExtraHours", or the name is ambiguous.
  </code></pre>
  
  <p>i have function which i got from stack yesterday and its is working perfect when i tested it in Management studio individually but when i put this in inline function and need to call in stored procedure then it throw mentioned error,</p>
  
  <p>function that i saved is :</p>
  
  <pre><code>ALTER FUNCTION dbo.udf_Sum_ExtraHours
      (
      @strt date,
      @end date
  
      )
  RETURNS  TABLE 
  AS
      RETURN
  
      WITH cte
  AS (
      SELECT ExtraHrs 
          ,CASE 
              WHEN left(ExtraHrs, 1) = '-'
                  THEN - 1
              ELSE 1
              END AS multiply
          ,right(ExtraHrs, 8) AS timestring
          ,
          --get hours in seconds:
          DATEPART(HOUR, right(ExtraHrs, 8)) * 3600 AS h_in_s
          ,
          --get minutes in seconds:
          DATEPART(MINUTE, right(ExtraHrs, 8)) * 60 AS m_in_s
          ,
          --get seconds:
          DATEPART(SECOND, right(ExtraHrs, 8)) AS s
      FROM  vw_Rept_Attend  where convert(date,AtnDate) between @strt and @end 
      )
      ,CTE3
  AS (
      SELECT *
          ,c.h_in_s + c.m_in_s + c.s AddExtra
      FROM cte c
      )
      ,cte4
  AS (
      SELECT sum(AddExtra * multiply) mn
      FROM cte3
      )
      ,cte5
  AS (
      SELECT mn / 3600 hh
          ,(mn % 3600) / 60 mi
          ,(mn % 3600.0) % 60 ss
      FROM cte4
      )
  SELECT 
      cast(hh AS VARCHAR) + ':' + cast(mi AS VARCHAR) + ':' + cast(ss AS VARCHAR) as ExtraHrs
  FROM cte5
  </code></pre>
  
  <p>now stored procedure from where i want to call this function is</p>
  
  <pre><code>     select   UserID,
  dbo.udfTimeSpanFromSeconds(Sum(Left(workhrs,2) * 3600 + substring(Convert(varchar(8),workhrs), 4,2) * 60 + substring(Convert(varchar(8),workhrs), 7,2))) as WorkHrs ,
  
  dbo.udf_Sum_ExtraHours('2015-10-12','2015-10-14'),// function which throw error
  
  EmpName,EmpType,UserName, Role,convert(VARCHAR(10),
  StartDate,105) as StartDate,convert(VARCHAR(10),EndDate,105) as EndDate
  from    vw_Rept_Attend  where  convert(date,AtnDate) between '2015-10-12' and '2015-10-14' 
  group by UserID,
  
  EmpName,EmpType,UserName, Role,StartDate,EndDate
        Order by UserID
  </code></pre>
  
  <p>but in SQL server management studio function give me accurate output when i execute individual function without using stored procedure</p>
  
  <p>out put in SQL management studio looking as:</p>
  
  <p><a href="https://i.stack.imgur.com/8Uk4X.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Uk4X.jpg" alt="enter image description here"></a></p>
  
  <p>i read</p>
  
  <p><a href="https://stackoverflow.com/questions/2091830/cannot-find-either-column-dbo-or-the-user-defined-function-or-aggregate-dbo-s">Cannot find either column &quot;dbo&quot; or the user-defined function or aggregate &quot;dbo.Splitfn&quot;, or the name is ambiguous</a></p>
  
  <p>and <a href="https://stackoverflow.com/questions/20651608/cannot-find-either-column-dbo-or-the-user-defined-function-or-aggregate-dbo-f">Cannot find either column “dbo” or the user-defined function or aggregate “dbo.FN_Split”, or the name is ambiguous</a></p>
  
  <p>and much more but cannot resolve my issue,</p>
  
  <p>please help me to get out of this,</p>
  
  <p>thanks </p>