CREATE a table from another table
Answers were Sorted based on User's Feedback
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 |
Is the log file is a part of file group?
i have 4 tables.. T1, T2, T3, T4.. these tables have the same structure and they store the information entered in different years.. T1 stored 2002, T2 stored 2003, T3 stored 2004 and T4 stored 2005.. i want to copy contents in T1 to T2, T2 to T3, T3 to T4 and T4 to T1.. how do i do that? Temp tables cannot be used..
How to use values from other tables in update statements in ms sql server?
Describe the functionalities that views support.
What are the purposes and advantages stored procedure?
Explain log shipping?
syntax and example for bitmap index in sql???
What is a transact-sql statement?
What is an index in a database?
Does sql server 2000 full-text search support clustering?
Can we do dml on views?
What is a derived table?