Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Introduction of Where class for filteration of Records Expand / Collapse
Author
Message
Posted Wednesday, July 1, 2009 5:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 1, 2009 5:07 AM
Points: 1, Visits: 41
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 +';';
..................................



  Post Attachments 
xgen_inserts.sql.txt (0 views, 5.22 KB)
Post #745246
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse