Create long SQL Insert Scripts

问题内容:

I get a list of ID numbers in excel. I need to manually create a SQL script to insert these values.

I managed to get a list of values like below into notepad++.

(@FeatureID,1,'00000000000'),
(@FeatureID,1,'00000000001'),
(@FeatureID,1,'00000000002'),

Now I want to use notepad++ to add the insert statement on every 1000th line to complete the SQL script.

Using regex (.*\r?\n){999}\K

Problem: The regex gets to line 999 but does not go to the end of the line.

Question: How do I get to the end of every 999th line, replace the comma add a new line and insert the following insert statement:

INSERT INTO feat.FeatureValidatorValue (FeatureId, ValidatorId, Value) 
    VALUES)

问题评论:

1  
Try (?:.*\R){999}.*\K,$ and replace with \r\nINSERT INTO feat.FeatureValidatorValue \(FeatureId, ValidatorId, Value\) VALUES)

答案:

答案1:

You almost had it – what you want to do is capture those 999 lines in a group and then for its replacement just add your desired string before the captured group:

Find:    ((.*\r?\n){999})
Replace: INSERT INTO feat.FeatureValidatorValue (FeatureId, ValidatorId, Value) VALUES \1

Make sure that . matches newline is not ticked.

答案评论:

原文地址:

https://stackoverflow.com/questions/47749530/create-long-sql-insert-scripts

添加评论

友情链接:蝴蝶教程