如何拆分冗长的插入命令行文本行? [英] How to split the Lengthy Insert Command Line Text Line ?

查看:54
本文介绍了如何拆分冗长的插入命令行文本行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的桌子有90个左右。现在我的问题是当我希望使用插入命令时

它没有执行...原因是命令非常冗长......那么如何分割线?



我的命令



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

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

DetailedInsert->ExecuteNonQuery();



因此DatiledInsert命令文本非常冗长,如何分割该行?



谢谢


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

Thanks

推荐答案

如果你的表有一个唯一的密钥(或者可能有几个列是唯一的,如果一起使用)你可以先插入一些列(包括唯一的列),然后使用几个更新命令更新行,例如:

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
update Table1 set col11 = val11, col12 = val12 ... col20 = val20
where col1 = val1;



假设第1列是您的唯一密钥。


assuming column 1 is your unique key.


这篇关于如何拆分冗长的插入命令行文本行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆