CREATE a table from another table

Answers were Sorted based on User's Feedback



CREATE a table from another table..

Answer / narendra

select *into newtable from oldtable.

Is This Answer Correct ?    4 Yes 0 No

CREATE a table from another table..

Answer / mohammadali.info

Syntax #1 - Copying all columns from another table

The basic syntax is:

CREATE TABLE new_table
AS (SELECT * FROM old_table);


For example:

CREATE TABLE suppliers
AS (SELECT *
FROM companies
WHERE id > 1000);

Syntax #2 - Copying selected columns from another table

The basic syntax is:

CREATE TABLE new_table
AS (SELECT column_1, column2, ... column_n FROM old_table);


For example:

CREATE TABLE suppliers
AS (SELECT id, address, city, state, zip
FROM companies
WHERE id > 1000);

Syntax #3 - Copying selected columns from multiple tables

The basic syntax is:

CREATE TABLE new_table
AS (SELECT column_1, column2, ... column_n
FROM old_table_1, old_table_2, ... old_table_n);


For example:

CREATE TABLE suppliers
AS (SELECT companies.id, companies.address, categories.cat_type
FROM companies, categories
WHERE companies.id = categories.id
AND companies.id > 1000);

Is This Answer Correct ?    4 Yes 5 No

Post New Answer

More SQL Server Interview Questions

What is log in sql server?

0 Answers  


What is the Control Flow in SSIS

0 Answers   HCL,


What is the security principal at the server level that represents your session?

0 Answers  


What is table constraint?

0 Answers  


1.what is the diff between nolock optimizer and read uncommitted isolation? 2.what is the diff between revoke and deny? 3.what is percieved down time? 4.whether password protection are required for backups?if yes why?if no why? 5.what is fill factor? 6.what is cost analysis? 7.what is mean by piece meal restore? 8.what is 'rowguidcol'? 9.impersonate permission? 10.what is selectivity?

0 Answers  






in the physical file layout, where should the transaction log be stored in relation to the data file?

0 Answers  


Define Unique Key?

0 Answers   HCL,


as a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this? : Sql server administration

0 Answers  


What are diverse clauses that form a part of sql?

0 Answers  


What are the characteristics of modern DBMS?

0 Answers   Ericsson,


How we Resize table,temp table, database and log file size in SQL Server 2005

1 Answers   ABC,


What is the bookmark lookup and rid lookup?

0 Answers  


Categories