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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -