Code Monkey home page Code Monkey logo

generate_inserts's People

Contributors

lambacck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

generate_inserts's Issues

Truncation problem on wide tables

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.

add 'date' to list on line 301

		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)

does not work

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.