generate insert script sql server

I’m using a backup database to do some testing.  This database already has data in it, but I would Like to add some additional data to it, possibly through a use rinterface and scripts.  If everything works well, I want to add the data that I added to backup database to another database.  I don’t want to have to do an export or Bulk Copy.  It seems like to many steps.  What I would rather have is just an insert statement the would crate the data. 
 
The following links are for script that generate insert statements:
 
This one is very simple, but I needed to change nvarchar(…)s to nvarchar(Max).
 
Here are some more links generate insert script for sql server
 
 
 

SQL Server Cursors With Dynamic SQL

First of all I do not recommend using Dynamic SQL or Cursors in production queries or stored procedures.  But they are a necessary evil sometimes.  When I do administrative queries or sp, dynamic SQL and cursors are very handy.
 
For example I needed to populate a table from meta data in two different tables.  I need the meta data to figure out what tables are needed to be use as a source for my query.  I have to create dynamic query, because at the time of execurting the stored procedure I don’t know which table and column should be used as the source.   After creating the dynamic SQL statement, I then need to loop through the results and create an insert statement for each record returned from the cursor.  Right now I won’t go into detail of the solution, but the follwowing code example helped alot.

[sourcecode language=”sql”]
DECLARE @my_cur CURSOR
EXEC sp_executesql
N’SET @my_cur = CURSOR STATIC FOR
SELECT name FROM dbo.sysobjects;
OPEN @my_cur’
,N’@my_cur cursor OUTPUT’, @my_cur OUTPUT
FETCH
NEXT FROM @my_cur
[/sourcecode]