BUG: Msg 170 While Creating View with * and an Expression

Last reviewed: April 10, 1997
Article ID: Q164169
The information in this article applies to:
  • Microsoft SQL Server, version 6.5
BUG #: 16594 (NT: 6.50)

SYMPTOMS

A CREATE VIEW statement fails with the following error message:

   Msg 170, Level 15, State 1
   Line%d: Incorrect syntax near ','.

This problem occurs if the select statement is something similar to either of the following:
  • Select *,<column_heading> = <expression> from <table name>

    -or-

  • Select *,<expression> <column_heading> from <table name>

where <expression> can be a column name, constant, function, or any combination of column names, constants, and functions connected by one or more operators, a CASE expression, or a subquery that returns one row.

WORKAROUND

To work around this problem, do either of the following

  • Qualify * with the table name.

    For example, use statements similar to the following:

          create view testview as
          select authors.*, today_date = getdate() from authors
    

    -or-

  • Instead of using * to select all the columns, specify all the columns by names separated by commas.

    For example, use statements similar to the following:

          create view testview as
          select au_id, au_lname, au_fname, phone, address, city, state, zip,
          contract, today_date = getdate() from authors
    

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

This problem is only occurs with the CREATE VIEW statement. The same select statement works fine inside a stored procedure, a trigger, or when run alone.


Additional query words:
Keywords : kbbug6.50 kbusage SSrvTran_SQL
Version : 6.5
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.