what is wrong with my query

  • CREATE TABLE ALL_HRHS_STAFF_test SELECT * FROM ALL_HRHS_STAFF_new

     

    It kept give me error

    Incorrect syntax near the keyword 'SELECT'.

    but  SELECT * FROM ALL_HRHS_STAFF_new have result show.

     

    Thanks.

     

     

  • The command you are looking for is SELECT INTO (see the books online)

    Example

    SELECT Shippers.*, Link.Address, Link.City,                   Link.Region, Link.PostalCodeINTO NewShippersFROM Shippers     JOIN LinkServer.DB.dbo.Shippers AS Link       ON (Shippers.ShipperID = Link.ShipperID)
  • Thanks. but I do not know why query is right which post on the other website.

  • You have two choices.

    1. Create a new table. Then insert all the rows from the old table into the new table (INSERT tblname SELECT * etc)

    or

    2. Use SELECT INTO. This creates the new table using the data from the original table.

    -SQLBill

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply