为一个供应商插入查询多种化学品 [英] insert query for one supplier multiple chemicals
本文介绍了为一个供应商插入查询多种化学品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须创建一个表来插入一个含有多种化学物质的供应商
我意思是:当我想从一个供应商那里购买化学品时,我已经为供应商创建了单独的表格,并为化学品单独创建了表格
Hi,
I have to create table to insert ONE SUPPLIER WITH MULTIPLE CHEMICALS
I mean: i have created separate table for supplier and separate table for chemicals, when i want to buy chemicals from one supplier
how should i create insert query for one supplier with many chemicals... and aslo ASP.NET page.
例如:
eg:
For Order Id 1, there can be 3 Items(say Item1,Item2,Item3)
For Order Id 2, there can be 5 Items(say Item 1.. Item5, all are comma seperated).
Next you want to insert the values into your database table
So the output will be like
TblOrders
OrderID Items
---------- --------
1 Item1,Item2,Item3
2 Item1,Item2,Item3,Item4,Item5
i不知道,根据我编写INSERT查询的数据,用户将选择多少项...
plzzz也建议FRONT END。
thnx
abdul subhan
i dont know, how many items will b selected by user, based on dat i have write INSERT query...
plzzz suggest FRONT END as well.
thnx
abdul subhan
推荐答案
使用存储过程,您最好的选择是将您的数据作为SQL传递并执行插入连接到创建的表,或使用表格值参数 [ ^ ]。我现在正准备一篇关于这些选项的文章,但距离大约一个星期了。
你似乎要求我们为你写一切。前端可以是您喜欢的任何内容,只要它在最后创建一个值列表,然后您可以按照自己喜欢的方式插入。如果系统使用率较低(如学校项目),您可以在循环中调用单个插入过程。无论你做什么,都不要做任何涉及将SQL构建为文本并执行它的事情,这总是一团糟。
Using a stored proc, your best bets are to pass your data in as SQL and do an insert joining to the table that creates, or to use a tabled valued parameter[^]. I am preparing an article on these options at the moment, but it's about a week away.
You seem to be asking us to write everything for you. The front end can be anything you like, so long as it creates a list of values at the end which you then insert any way you like. If the system is low use ( like a school project ) you could get away with calling a single insert proc in a loop. Whatever you do, don't do anything that involves building SQL as text and executing it, that's always a mess.
发出多个INSERT命令(最好在一个Transaction中)或者做一个多重组件行插入:
Either issue multiple INSERT commands (preferably within a Transaction) or do a multiuple row insert:
INSERT INTO MyTable (Col1, Col2) VALUES
(1, 2)
(1, 3)
(1, 4)
(2, 1)
(2, 2)
...
每组值都会得到一个新行。
Each set of values will get a new row.
参考
http://blog.sqlauthority.com/2008/07/02/sql-server-2008-insert-multiple-records-using-one- insert-statement-use-of-row-constructor / [ ^ ]
这篇关于为一个供应商插入查询多种化学品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文