0

I have function like this in asp.net :

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"]));
}

What is the equivalent of this code in SQl? Can we execute both of select and update in one procedure ?

Farzaneh Talebi
  • 835
  • 4
  • 22
  • 47

1 Answers1

-1

Yes it is possible in 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.

Select and update in single statment : How do I UPDATE from a SELECT in SQL Server?

Using temp table : In SQL Server, how to create while loop in select

Community
  • 1
  • 1
Kaushik Maheta
  • 1,741
  • 1
  • 18
  • 27