Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi, I have table around 90 Columns. Now my problem is when I wish to use the Insert Command
it's not executing... The reason is that the command is very lengthy... So how to split the line ?

My Command

C++
SqlCommand^ DetailedInsert = gcnew SqlCommand("Insert into Table1 (col1,col2,col3,...col90) values (val1,val2,val3,...val90)", SqlCon);

DetailedInsert->ExecuteNonQuery();

So that DatiledInsert Command Text is very lengthy, How to split that line?

Thanks
Posted
Updated 20-Nov-13 22:30pm
v3
Comments
KarstenK 21-Nov-13 4:44am    
Consider to redesign the database. Use some redunancy to clean up the fat tables. If you have different tables, the statement will get lighter.

This bad design will result in low performance of all operation.
agent_kruger 21-Nov-13 4:49am    
why do you need 90 columns?
CPallini 21-Nov-13 4:51am    
What is the error you get? Such a huge number of columns is probably poor design, however, I suppose, the database (and code) should handle it correctly.

1 solution

If your table has a unique key (or possibly several columns that are unique if taken together) you can first insert some columns (including the unique one(s)) and then update the row with several update commands like this
SQL
update Table1 set col11 = val11, col12 = val12 ... col20 = val20
where col1 = val1;

assuming column 1 is your unique key.
 
Share this answer
 
Comments
Paramu1973 21-Nov-13 6:03am    
Nope...Its my requirement for diffrent purpose, so all comments are not gives a solution.....to my requirement

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900