CREATE a table from another table

Answers were Sorted based on User's Feedback



CREATE a table from another table..

Answer / narendra

select *into newtable from oldtable.

Is This Answer Correct ?    4 Yes 0 No

CREATE a table from another table..

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

Post New Answer

More SQL Server Interview Questions

How to check if stored procedure is running in sql server?

0 Answers  


Describe about first three Normal forms.

1 Answers   HP,


SYNTAX FOR VIEWS WITH EXAMPLE HOW TO LINK TWO TABLES

1 Answers   Microsoft,


What is 'write-ahead log' in sql server 2000 ?

0 Answers  


What is The Use Of TIMESTAMP DataType in SQL Server 2005?

6 Answers  






What is right outer join in sql server joins?

0 Answers  


Suppose in a situation if two list boxes are there and if you select multiple options based on that the options related to those selected items should display in second list box. Again if we select multiple items in second listbox then the related to those selected items should display . In this scenario how will you design database,tables?

1 Answers   HP,


wat is mean by normalization?......programing defination i need...(i know basic defination)

4 Answers   Wipro,


How much is a sql server license?

0 Answers  


how to update a null value field in sql server eg a table contains 3 fields id,name,salary and 3 records salary of 1 record is null i want update the nullfield 111 arun 300 112 ddd 200 113 ttt null i want to update table with add 100 to every record include null after updation the recrds should be 111 arun 400 112 ddd 300 113 ttt 100

6 Answers   ABC, HCL,


CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType varchar(50) ) go create trigger hpms_create_Insert on HPMS_CompetencyTypes for insert as if Exists ( select * from [HPMS_CompetencyTypes] where CompetencyType=(select * from [HPMS_CompetencyTypes])) begin Rollback tran Raiserror ('duplicate value',12,6) go insert HPMS_CompetencyTypes (CompetencyType) values ('new') I'm new to trigger can any one tell me where is the issue. Please.

2 Answers  


What are the new features in SQL Server 2005 when compared to SQL Server 2000?

0 Answers  


Categories