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 |
How to select true false based on column value in sql server?
How to create a simple stored procedure in ms sql server?
What is Transparent Data Encryption?
How to handle errors in Stored Procedures.
What is the maximum length of an alert name?
What is dirty read?
Differentiate between a having clause and a where clause.
How do I setup a sql server database?
There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better?
Explain the properties of subqueries in sql server?
Why Do you want to work in this company?
What are the ways available in sql server to execute sql statements?