DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to apply select into table?

Execute the following T-SQL scripts in Microsoft SQL Server Management Studio Query Editor to demonstrate the use of SELECT...INTO T-SQL statement for the creation of a new table and populating it instantly.

use AdventureWorks;

 

-- Creates table dbo.Product in AdventureWorks database

select * into Product from Production.Product

 

-- Creates temporary table #Product in tempdb

select * into #Product from Production.Product

 

use tempdb;

 

-- Creates table dbo.Product in tempdb

select * into Product from AdventureWorks.Production.Product

 

-- Creates dbo.Product1 with subset of columns, IDENTITY ON for ProductID

select ProductID, ProductName=Name, ListPrice

into Product1 from AdventureWorks.Production.Product

 

exec sp_help Product1

 

-- Creates dbo.Product2 with IDENTITY turned OFF

select ProductID=convert(int,ProductID), ProductName=Name, ListPrice

into Product2 from AdventureWorks.Production.Product

 

exec sp_help Product2

 

-- Table can be doubled in size for testing/simulation with each INSERT

insert Product2 select* from Product2

insert Product2 select* from Product2

insert Product2 select* from Product2

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE