Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Insert Script Generator

By Linson Daniel,

This stored procedure basically takes the data present in the tables and creates the insert script for the particular table taking care of the datatypes. However datatypes like image have not been handled here. But it could be added on.

This stored procedure has an optional parameter wherin the user can enter the list of table names seperated by commas. Otherwise it could be run without any parameters which in turn would script for all the tables present in that particular database.

The advantages of this stored procedure are

  • It takes of almost all datatypes while insert script generation
  • Script for specific tables can created or for the entire tables in the database
  • It also handles the identity columns wherein the identity columns will not appear in the insert script generated.

The disadvantages of this stored procedure or improvement areas would be:

Well I cant think of any ...(joking).ofcourse there are and it would be

  • It is kinda like an sql developer's nightmare with lots of cursors and dynamic query execution.
  • The Datatype uniqueidentifier here is handled such that the new ids are inserted and not the one that was present in the tables.

 

Note:

There are more better ways to do the same thing and lots of improvements could be added on to it. So please do contribute with your suggestions.

 

 

 

Total article views: 2373 | Views in the last 30 days: 14
 
Related Articles
SCRIPT

Insert Generator - Stored Procedure

Stored procedure to generate an insert script for a table.

SCRIPT

Insert Update Stored Procedure for a table

Generic Script for Insert Update Stored Procedures

FORUM

Scripting Stored Procedures

Scripting Stored Procedures

ARTICLE

Dynamic creation of Insert, Update, Delete Stored procedures

Automates the creation of INSERT, UPDATE & DELETE stored procedure of a table

FORUM

stored procedure vs individual insert statements

stored procedure vs individual insert statements

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones