SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Sp_generate_inserts fails
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kvramana
Starting Member

1 Posts

Posted - 07/09/2013 :  09:04:13  Show Profile  Reply with Quote
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

USA
4 Posts

Posted - 07/09/2013 :  14:15:57  Show Profile  Reply with Quote
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

USA
4 Posts

Posted - 07/09/2013 :  14:34:04  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000