Bulk Insert
Type 2 :
- we can use two types of bulk insert in MSSQL
- it is very useful to transfer whole data or particular data from one table to another
- Type 1: we need to create schema or we can use existing schema for insertion
- Type 2: we cannot insert data's in existing table schema.this type will copy the schema of selected table and create table in database or we can use temp table
- Mostly this bulk insert are used in stored procedure or user-defined functions for calculations.
CREATE TABLE TABLE1( name INT,EmpSalary BIGINT) INSERT INTO TABLE1 SELECT name,salary FROM TABLE2 WHERE salary > 1000
Type 2 :
SELECT * INTO #TEMP FROM TABLE2 //this will create temp table with selected table schema WHERE salary > 1000 OR SELECT * INTO TABLE FROM TABLE2 // this will create real table with selected table schema in DB WHERE salary > 1000
No comments:
Post a Comment