Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Collapse TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Expand Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Expand CursorCursor
Expand OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Expand Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Expand v.IMP Queriesv.IMP Queries
Expand XMLXML
Expand Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Expand CreateCreate
     

Insert values into Table

 
EMP
ID Name Country Salary
1 Vijay India 6000
2 Bill USA 8000
3 Kris France 3000
---- to insert Data into ALL fields
INSERT INTO EMP1 VALUES(4,'Steve','USA',9000)
---- to insert Data into SPECIFIC fields
INSERT INTO EMP1(Name,Salary) VALUES('Jill',7000)
---- to insert Data into Table from another Table (both Tables Must Exist)
INSERT INTO EMP1 SELECT * FROM EMP
---- Create New Table and Insert Data from existing Table
SELECT * INTO myNewTable FROM EMP
---- to insert Data into Multiple Rows
INSERT INTO EMP (ID, Name, Country, Salary) SELECT 1, 'Vijay', 'India', 6000 UNION ALL SELECT 2, 'Bill', 'USA', 8000 UNION ALL SELECT 3, 'Kris', 'France', 3000 GO
---- Bulk Insert, inserting data from Text file to Table Create a “data.txt” with following data and save at C: ID, Name, Country; 1, Vijay,India; 2, Bill, USA; then run the following query
BULK INSERT EMP FROM 'c:\data.txt' WITH ( FieldTerminator = ',', RowTerminator = ';' )