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 do you migrate data from mssql server to azure?
Why and when do stored procedure recompile?
When columns are added to existing tables, what do they initially contain?
What is table valued function and scalar valued functions?
what are the different ways to return the rowcount of a table?
on line cluster can we make if yes tell me the procedure
What is Dependency Injection and provide example?
Which rendering formats are affected by the pagesize properties?
Define left outer join in sql server joins?
What happens if we shrink log file in sql server?
What type of Index will get created after executing the above statement?
Is it possible to import data directly from t-sql commands without using sql server integration services? If so, what are the commands?
What is a virtual table in sql?
What are the steps you will take to improve the performance of a poor performing query?
What is multilevel indexing?