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
What is a unique key constraint?
What do you understand by the analysis services in sql server?
How to check if a table is being used in sql server?
How to concatenate two character strings together?
Does server sql treat char as a variable-length or fixed-length column?
What is resource governor?
How do you send email on SQL Server?
When should you use an instead of trigger?
Do you know what are acid properties?
How to delete duplicate rows?
What is a user-defined function in the sql server and what is its advantage?
What is ssl in sql server?
What are views in ms sql server?
What are the differences between stored procedure and the dynamic sql?
What is the maximum row of a size?