Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Sp_generate_inserts fails

Author  Topic 

kvramana
Starting Member

1 Post

Posted - 2013-07-09 : 09:04:13
Iam using "exec Sp_generate_inserts 'tablename'" to generate insert script to tables.
It is generating insert scripts sucessfully for all tables except one which is having 120 columns.Any solution for this??

jrea8830
Starting Member

4 Posts

Posted - 2013-07-09 : 14:15:57
Assuming you are using Narayana Vyas Kondreddi's script found at: http://vyaskn.tripod.com/code/generate_inserts.txt, then there is a limitation documented in the script:

quote:
NOTE: This procedure may not work with tables with too many columns.
Results can be unpredictable with huge text columns or SQL Server 2000's sql_variant data types
Whenever possible, Use @include_column_list parameter to ommit column list in the INSERT statement, for better results
IMPORTANT: This procedure is not tested with internation data (Extended characters or Unicode). If needed
you might want to convert the datatypes of character variables in this procedure to their respective unicode counterparts
like nchar and nvarchar


The script documents the ability to specify column to include or to exclude when generating the insert statements.

I've never used the script; however, reviewing the script's coding it looks as though there is no work around other than generating an INSERT with fewer columns. Maybe you can exclude columns where most results are NULL and manually create an update statement to follow the generated INSERT statement adding in the data from the missing columns?
Go to Top of Page

jrea8830
Starting Member

4 Posts

Posted - 2013-07-09 : 14:34:04
A little more indepth analysis shows if you were to change two decleration variables "@Column_List" and "@Actual_Values" from being VARCHAR(8000) to VARCHAR(MAX) then you can get by the column length limitation....again, this is assuming you are using the script mentioned in my previous response.
Go to Top of Page
   

- Advertisement -