Answer Posted / 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 View All Answers
How to implement service broker?
What do you understand by the data quality services in sql server?
Why do we need different type of parameter?
What is the difference between Triggers and Stored Procedure?
What action plan is preferred if sql server is not responding?
what is bit datatype and what's the information that can be stored inside a bit column? : Sql server database administration
What is a linked server in sql server?
What are the types of database recovery models?
What are the different types of subquery?
You want to implement the one-to-many relationship while designing tables. How would you do it?
What is the difference between sql server 2000 object owner and sql server 2005 schema? : sql server database administration
What are the kinds of subquery?
What are the 2 types of classifications of constraints in the sql server?
Can a table be created inside a trigger?
What is the syntax for encrypting a column in SQL Server?