2015-12-01 22 views
0

的每一行執行代碼,我在asp.net這樣的功能:找到所有行和SQL

DataTable dt = dal.ExecuteDataTable(CommandType.Text, "SELECT KID FROM Chart", new SqlParameter[] { }); 

for (int i = 0; i < dt.Rows.Count; i++) 
{ 
    Update(Convert.ToInt64(dt.Rows[i]["KID"])); 
} 

這是什麼代碼在SQL中的相同呢?我們可以在一個程序中同時執行select和update嗎?

+0

什麼是你想在這裏實現?你試圖解決什麼問題? – user5151179

+0

我想在SQL中同時執行select和update而不是asp.net – Farzaneh

回答

-1

是的,它可能在SQL中。

1. Create temporary table in SQL. 
2. Insert data into temporary table. 
3. Access temp table data using while loop. 
4. update single record one by one in while loop. 

選擇並單statment更新:How do I UPDATE from a SELECT in SQL Server?

使用臨時表:In SQL Server, how to create while loop in select

+0

您能告訴我一個簡單的例子嗎? – Farzaneh

+0

@downvoter,爲什麼要投票? –

+1

那不是我的 – Farzaneh