I\'m trying to perform a series of SQL*Server steps using dapper from C#. One step creates a temp table and populates it. Following steps query data from the temp table.
The following works perfectly for me:
db.Open();
db.Execute(
@"create table #foo (val int not null);
insert #foo (val) values (123)");
db.Execute(
@"insert #foo (val) values (456)");
var vals = db.Query(
@"select * from #foo").ToList();
foreach(var val in vals)
Console.WriteLine(val);
It also works perfectly if I use:
@"select * from tempdb..#foo"
The only way I can cause it to stop working is, as per my previous answer, to not open the connection first.