Copy Table From One Table To Another Table In SQL Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amit tank
    New Member
    • May 2010
    • 1

    Copy Table From One Table To Another Table In SQL Server

    Hi All,

    I Want To Copy Table Data From One Table To Another Both Table Name Are Same But in Other Database
    I Tried This

    Code:
    SELECT * INTO DIMS1.dbo.MstCmp
     FROM DIMS.dbo.MstCmp where 1>2
    But This Doesn't Work When Both Tables Are Same


    So Please Help Me Out For This.

    Thanks And Regards..
    AMIT TANK
    Last edited by NeoPa; Sep 15 '10, 01:47 PM. Reason: Please use the [code] tags provided
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32653

    #2
    That would never work in any circumstances as your WHERE clause specifies to copy only when 1 is greater than 2 (which is by definition FALSE).

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      To add to Neo's response...

      Your command will copy the table, but not the content, not the index, not the trigger, not any constraint, just the structure. You'll have an empty table...

      Happy Coding!!!

      ~~ CK

      Comment

      Working...