SQL Server Index Screwup??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas G
    New Member
    • Dec 2011
    • 1

    SQL Server Index Screwup??

    Hi,

    I am using an order by on a standard Insert .. Select into query. It is listed below. When I put an order by into the select statement, it gives an error of 'Incorrect syntax near the keyword 'order'.' However, if I remove the order by it works fine. If I run the select statement by itself, it works fine. Also, eventhough the records where inserted by a previous insert trigger, they still are not defaultly in the same order. Any ideas, or is this just a SQL Server index Opps?

    Actual Query
    (Description:
    TransactionData is the original table
    ArchivedTransac tionData is the triggered insert table)

    (NOTE: The query is intended to be restoring data from the Archived version)
    --------------------------
    Code:
    insert into TransactionData (BasketTag,UserTag,[Weight],crtdDateTime,Station,GroupID) 
    (select BasketTag,UserTag,[Weight],crtdDateTime,Station,GroupID from ArchivedTransactionData where crtdDateTime > '12-22-2011' order by crtdDateTime)
    --------------------------
    Last edited by NeoPa; Dec 25 '11, 12:56 AM. Reason: Added mandatory [CODE] tags for you
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32653

    #2
    I don't believe the ORDER BY clause is valid within an INSERT INTO action query as it would make no sense and could have no possible meaning.

    Comment

    Working...