SQL Server: view or function contains a self-reference. Views or functions cannot reference themselves directly or indirectly
<p>I'm trying to change the date format of a column stored in a view by doing an <code>ALTER VIEW</code> statement, but it's not working and I'm not sure why.</p>

<p>My query:</p>

<pre><code> ALTER VIEW v_cust_invoices
 AS
     SELECT 
         FORMAT(INV_DATE,'MM-dd-yy') as INV_DATE
     FROM 
         v_cust_invoices
</code></pre>

<p>I always get the error </p>

<blockquote>
  <p>View or function 'v_cust_invoices' contains a self-reference. Views or functions cannot reference themselves directly or indirectly</p>
</blockquote>

<p>I'm trying to change the date format of <code>INV_DATE</code> to <code>mm-dd-yy</code> (it's currently <code>yy-mm-dd</code>). Can someone help me? Not sure what I'm doing wrong.</p>

<p>Edit: If I do</p>

<pre><code> ALTER VIEW v_cust_invoices
 AS
     SELECT FORMAT(INV_DATE,'MM-dd-yy') as INV_DATE
     FROM INVOICE
</code></pre>

<p>instead, it deletes all of the columns except for <code>INV_DATE</code>.</p>

<p>View definition:</p>

<pre><code>SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[v_cust_invoices] AS 
    SELECT 
        CUSTOMER.CUST_NUM, CUST_LNAME,
        CUST_BALANCE, INV_NUM, INV_DATE, INV_AMOUNT 
    FROM 
        CUSTOMER, INVOICE
GO
</code></pre>