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.
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.