#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    49
    Rep Power
    14

    copy table in mssql


    How do I copy a mssql table? I have tablex and want to create a dublicate and call it tablex_b. Is there a sql statement that can do this?
    Auction off your web site real estate.

    http://www.webmasterbids.com
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    not sure about the mssql syntax, you should check your documentation to be sure, but it should be something like this:
    Code:
    create table sometablename like some_other_table_name
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    49
    Rep Power
    14
    Oh really, it is just that simple? and that will create the new table and populate it with the existing records?
    Auction off your web site real estate.

    http://www.webmasterbids.com
  6. #4
  7. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    No, it will just create a table with the exact same structure.
    To copy the structure and fill it with the same data you might (not sure) can do this
    Code:
    create table sometablename as (select * from some_other_table_name)
    You will have to check your documentation to be sure.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    SELECT *
    INTO newTable
    FROM oldTable
    GO
    El éxito consiste en una serie de pequeñas victorias día a día

    MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html

IMN logo majestic logo threadwatch logo seochat tools logo