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

Insert Script Generator

By Linson Daniel, 2009/01/12

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: 2256 | Views in the last 30 days: 24
 
Related Articles
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

FORUM

Insert Update Stored Procedure - HELP

Problem with insert update stored procedure

 
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