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 an execution plan? How would you view the execution plan?
What is a partition key?
Is sql server difficult to learn?
How we can compare two database data?
What are parameterized reports?
What does it mean to manipulate data?
What is a benefit of using an after insert trigger over using a before insert trigger?
How to create a stored procedure with a statement block in ms sql server?
How to delete duplicate rows?
What is explicit mode in sql server?
What happens when converting big values to integers?
I have triggers,views,functions,stored Procedures for a table. When I am dropping that table which objects are deleted?
Why should we go for stored procedures? Why not direct queries?
What are the filtered indexes?
What is user defined stored procedures?