-2
这是我的第一个表While循环存储过程
表1:
CatID TenderNumber
1 AA01012013
2 AA01012013
3 AA01012013
表2:
SubCatID CatID
1 1
2 1
3 2
4 2
5 2
6 3
所以这是我的数据库看起来像。现在我想使用C#将SubCatID
和CatID
存储到新表中。这些值将从TenderNumber
仅作如下检索:
Select CatID from Table1 where TenderNumber='AA01012013'
while(SQLDataReader1.read())
{
select SubCatID from Table2 where CatID=Reader1["CatID"]
While(SQLDataReader2.read())
{
insert into Table3(SubCatID,CatID)Values(Reader2["SubCatID"],Reader1["CatID"])
}
}
我怎样才能做到这一点使用存储过程?
我想在C#中使用存储过程执行此操作 – punter
@punter **为什么要在C#中执行此操作?或者用'while'循环?甚至是存储过程?这只是一个单行的基于set的'insert'语句,不是? –
@MarcGravell这只是我实际需求的一个示例。 – punter