Combining query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • loisk
    New Member
    • Sep 2007
    • 97

    Combining query

    Hi,

    Can anybody tell me if the query below is valid in combining truncate table and insert into?

    " TRUNCATE TABLE tblname INSERT INTO tblname SELECT Caseid,Batch,Ou tcome,Spanish,S aqlang,Typecomp FROM otherTblname WHERE x=xx ;"

    I need to make empty one table before I add data from other table to it. Thanks!
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    As far as I know and have always seen, TRUNCATE TABLE is an individual SQL statement and should be executed as such.
    So you'll have to make 2 statements and execute them either separately or store them in a Procedure.

    Ronald

    Comment

    • loisk
      New Member
      • Sep 2007
      • 97

      #3
      Originally posted by ronverdonk
      As far as I know and have always seen, TRUNCATE TABLE is an individual SQL statement and should be executed as such.
      So you'll have to make 2 statements and execute them either separately or store them in a Procedure.

      Ronald
      I've tried using DELETE FROM xxx and it seems to be the same case. Am I right? Thanks!

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Yes it is, almost. DELETE returns the number of rows deleted, TRUNCATE does not.

        Ronald

        Comment

        Working...