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

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.

Keywords : kbusage SSrvTran_SQL kbbug6.50
Version : 6.5
Platform : WINDOWS
Issue type :


Last Reviewed: April 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.