Different ways of inserting records into tables using SQL query
In this article I am going to explain how to insert records into table using multiple methods in MS SQL
In this article I'm going to explain how to insert records into table using multiple methods.
To Create table :-
Create Table StudentMark(StudentID Int,StudentName VArchar(max),Mark int)
Insert one row at a time
insert into StudentMark values(1000,'Renganathan',500)
insert into StudentMark values(1001,'Ravi',600)
insert into StudentMark values(1002,'kumar',700)
Insert bulk rows into table retuned by the query
insert into StudentMark select * from StudentMark
Select table and insert table schema should match.
Insert query result into new table
select * into StudentMarkCopy from StudentMark
Inserting table in this query should not exist in database before executing this query.
Insert rows into table returned by stored procedure
insert into StudentMarkCopy exec spGetEmpDetails
Number of columns returned by stored procedure shoud match with the inserting table(StudentMark).