sql server - Is their any advantage of using Insert Query in different form in sqlserver stored procedure? -
i have seen stored procedures
written following two formats:
method 1: insert tablname(col1,col2) values (@col1,col2) method 2: insert tablname(col1,col2) select @col1,@col2
i curious know whether advantage of method1 or method2 ? reason?
thanks!
there's not performance difference. it's matter of preference.
but method:2 can below insert multiple records:
insert tablname(col1,col2) select @col1,@col2 union select @col2,col4
from sql server 2008 (row construction) onwards, can below method 1:
insert tablname (col1, col2) values (1, 'first'), (2, 'second'), (3, 'third');
for more info, check out this link.
Comments
Post a Comment