Creating Tables Using SELECT

Answer Posted / mohammadali.info

*SELECT...INTO essentially combines CREATE TABLE and SELECT in a single statement. The AS clause can be used to change the column labels and thus control the column names in the new table. The other commands in the figure show the new table's structure and contents.

-SELECT firstname, lastname, city, state
INTO newfriend
FROM friend;

-SELECT...INTO tablename can also be written as CREATE TABLE tablename AS SELECT.... The preceding query can then be rewritten as
CREATE TABLE newfriend AS SELECT firstname, lastname, city, state FROM friend.

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the purpose of indexes?

718


Why use “pivot” in sql server?

774


Explain the dbcc pintable command when would you use it?

680


Do you know exporting and importing utility?

694


Tell me what is the order in which the sql query is executed?

699






When multiple after triggers are attached to sql table, how to control the order of execution?

731


What is user defined stored procedures?

713


What are the difference between clustered and a non-clustered index?

751


What is sql sandbox in sql server?

818


what is checksum in sql server.........???

1373


List out the difference between union and union all in sql server?

674


What are the new features of sql server 2008 r2 reporting service?

124


What is the cartesian product of table?

721


What are the restraints imposed on the table design by a merge replication?

787


How to optimize stored procedures in sql server?

822