如何使用存储过程将一个 table 更新为另一个 table 数据集?
How to Update one table by another table datas using storedprocedure?
我有一个名为 Dummy
的 Table,带有标记和学生 ID(有 3 个标记字段)。我还有一个 table Applicantdetails 这个 table 也包含标记字段。我想做的是根据学生 ID 将 Dummy tables 标记更新为 Applicantdetails table 标记。我想通过 mssql Storedprocedure 来做到这一点。任何方式来实现它。如果我们以代码的方式编写它应该是这样的
qry="select Applicantid,mark1,mark2,mark3 from Dummy"
//saved result to Datatable dt
foreaach(DataRow. rows in dt.rows)
{
string id=Convert.ToString(row["ApplicantID"].tostring();
string mark1=Convert.ToString(row["ApplicantID"].tostring();
string mark2=Convert.ToString(row["ApplicantID"].tostring();
string mark3=Convert.ToString(row["ApplicantID"].tostring();
qry="update Applicantdetails set Mark1=mark1,Mark2=Mark2,Mark3=Mark3
where ApplicantID=id";
}
我想在存储过程中引入这种格式..请帮助我
您的存储过程会收到@applicationid 吗?否则它将全部更新,使用以下内容创建一个存储过程 SQL
UPDATE A
SET Mark1= d.mark1, Mark2 = d.mark2, Mark3= d.mark3
FROM ApplicationDetail A
JOIN Dummy d on d.Applicationid = A.Applicationid
我有一个名为 Dummy
的 Table,带有标记和学生 ID(有 3 个标记字段)。我还有一个 table Applicantdetails 这个 table 也包含标记字段。我想做的是根据学生 ID 将 Dummy tables 标记更新为 Applicantdetails table 标记。我想通过 mssql Storedprocedure 来做到这一点。任何方式来实现它。如果我们以代码的方式编写它应该是这样的
qry="select Applicantid,mark1,mark2,mark3 from Dummy"
//saved result to Datatable dt
foreaach(DataRow. rows in dt.rows)
{
string id=Convert.ToString(row["ApplicantID"].tostring();
string mark1=Convert.ToString(row["ApplicantID"].tostring();
string mark2=Convert.ToString(row["ApplicantID"].tostring();
string mark3=Convert.ToString(row["ApplicantID"].tostring();
qry="update Applicantdetails set Mark1=mark1,Mark2=Mark2,Mark3=Mark3
where ApplicantID=id";
}
我想在存储过程中引入这种格式..请帮助我
您的存储过程会收到@applicationid 吗?否则它将全部更新,使用以下内容创建一个存储过程 SQL
UPDATE A
SET Mark1= d.mark1, Mark2 = d.mark2, Mark3= d.mark3
FROM ApplicationDetail A
JOIN Dummy d on d.Applicationid = A.Applicationid