how to create new table from existing table in sql server

I want to use only one query - the problem is: how to create new table from existing table in sql server

Replies

  • Leo
    Leo
    create table newtable_name like database_name.old_table_name;

    insert into newtable_name selcet * from database_name.old_table_name;

    This will copy your previous table to new table. Happy computing.
  • Sahithi Pallavi
    Sahithi Pallavi
    create table new-table-name (column-list) as select (column-list) from existing-table-name;

    What's this then?
  • Saandeep Sreerambatla
    Saandeep Sreerambatla
    In Oracle,

    Create table temp as select * from old table. -- will this not do?
  • Sahithi Pallavi
    Sahithi Pallavi
    English-Scared
    In Oracle,

    Create table temp as select * from old table. -- will this not do?
    This is same as the query I have given.

    create table new-table-name (column-list) as select (column-list) from existing-table-name;

    In your query, temp is the new-table-name and old table refers to the existing-table-name. I had specified the column-list to select particular columns and you used * to select all the columns, Isn't it?

    This will definitely works.
  • bohar
    bohar
    select * into table_new from table_old
    this query work in sqlserver,but i have no idea that about, this will work in oracle,mysql or not
  • 4M4N
    4M4N
    Suppose u have table employee having cols eno, ename, salary and adress, now for making exact copy of that table of name emp2 the following query can be used

    create table emp2(eno int, ename varchar(50), salary int, address varchar(50)) select eno , ename , salary , address from employee;
    (tested)

You are reading an archived discussion.

Related Posts

Hi frnds.. Using piezoelectric mtls to convert mechanical power to electrical power is costlier, can we replace it with any other material.๐Ÿ˜•๐Ÿ˜• ๐Ÿ˜๐Ÿ˜๐Ÿ˜
CEans, Lot of members have asked about the userID "CE-InFocus". Let me update - CE-InFocus is a bot that grabs the feed from our official blog 'VoiCE' and posts a...
Hello CEans, We are back with a new KYCEan. It's CEan whiz.kid.aniket who loves computers and techno music equally. He has joined the CE Forum in February, 2010 and has...
๐Ÿ˜ Wishing both the CEans a very happy birthday! ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰
Hello friends, I have some read about zero address instruction.Such type of instruction is found in machine that store operand in a structure called a pushdown stack. This theory is...