Skip to content
Advertisement

Insert into table multiple rows with one different value

I believe my question is kinda simple but I haven’t found something like that upon searching. I want to insert into a table testing multiple rows for example:

(’03’,’ENG’,’203′) (’03’,’ENG’,’403′) (’03’,’ENG’,’155′) (’03’,’ENG’,’222′) (’03’,’ENG’,’456′) (’03’,’ENG’,’111′) …

Instead of writing

Is there any faster way to write something like

It would be even better if I did not have to use dynamic sql. Thanks in advance.

Advertisement

Answer

I’m not sure if it is that much simpler, but you can use insert . . . select with a values() clause for the third column:

If you have a list of column3’s in a table and you have no duplicates, you can use:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement