sometime we do not need to gen inserts for all records so i put a very little change in it.
as my situation i need to generate inserts scripts for only those records which fulfill the certain criteria. so i just make these two changes in it. Thanks to original writer anyways 🙂
Please find modified code attached with topic
Two steps only
1) Add new Parameter in storeprocedure
LTER proc [dbo].[usp_generate_inserts]
(
@table nvarchar(255),
@where nvarchar(255)
)
as.....
2) Alter the script and concat where clause string at the end
set @script =
'select ''insert into ' + @table + ' (' + substring(@columns, 3, len(@columns)) +
') values ('' + ' + substring(@values, 11, len(@values)) + ' + '');'' from ' + @table + ' where '+ @where +';';
..................................