I need to pass data among a list of stored procedures. The way this needs to be done is by using a local temp table.
var createTempTableCommand = new SqlCommand("Create table #mytemptable ....", myconnection);
using (SqlDataReader dr = createTempTableCommand.ExecuteReader())
{
// ...
}
foreach(command in listOfSqlCommands)
{
using (SqlDataReader dr = command.ExecuteReader())
{
dtResults.Load(dr);
}
}
How do I ensure that the temp table that has been created #mytemptable remains intact during the foreach iteration?