lambacck / generate_inserts Goto Github PK
View Code? Open in Web Editor NEWGenerate SQL Insert Statements from your existing data
Generate SQL Insert Statements from your existing data
If a table has many columns and lengthy column names, the generated select statement can be incomplete due to truncation . This leads to unpredictable errors or potentially invalid results. In my specific case, I was getting the following results:
PRINT 'Inserting values into [tblsaLocationMaster]'
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string 'Purchas'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'Purchas'.
PRINT 'Done'
Debug mode showed the last few characters of the generated select statement were:
+ REPLACE(RTRIM([Purchas
If the truncation occurred in just the right place, the symptom could be that the command succeeds, but some of the columns are not included in the output.
Changing the @Actual_Values variable from varchar(8000) to varchar(max) resolves the problem.
WHEN @Data_Type IN ('char','varchar','nchar','nvarchar')
->
WHEN @Data_Type IN ('char','varchar','nchar','nvarchar','date')
currently dates generate unquoted which sql server will not convert to date
(could also cast or convert to date but believe it is never required for date)
this is the output i get
Msg 537, Level 16, State 2, Procedure sp_generate_inserts, Line 333 [Batch Start Line 0]
Invalid length parameter passed to the LEFT or SUBSTRING function.
Msg 537, Level 16, State 2, Procedure sp_generate_inserts, Line 334 [Batch Start Line 0]
Invalid length parameter passed to the LEFT or SUBSTRING function.
Msg 50000, Level 16, State 1, Procedure sp_generate_inserts, Line 338 [Batch Start Line 0]
No columns to select. There should at least be one column to generate the output
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.