M
Mark Rendle
For some reason, if I create a temporary table in a SqlCommand which has
parameters, it doesn't get created properly, although no exception is
thrown and ExecuteNonQuery returns the correct number of rows.
So
cmd.CommandText = "create table #temp (col int); insert into #temp values
(1)";
cmd.Connection.Open();
cmd.ExecuteNonQuery(); // returns 1, temp table has been created in tempdb
works fine, but
cmd.CommandText = "create table #temp (col int); insert into #temp values
(@param)";
cmd.Parameters.Add("@param", 1);
cmd.Connection.Open();
cmd.ExecuteNonQuery(); // returns 1, temp table has not been created.
fails utterly.
Is there a proper reason for this or is it just another one of those things?
parameters, it doesn't get created properly, although no exception is
thrown and ExecuteNonQuery returns the correct number of rows.
So
cmd.CommandText = "create table #temp (col int); insert into #temp values
(1)";
cmd.Connection.Open();
cmd.ExecuteNonQuery(); // returns 1, temp table has been created in tempdb
works fine, but
cmd.CommandText = "create table #temp (col int); insert into #temp values
(@param)";
cmd.Parameters.Add("@param", 1);
cmd.Connection.Open();
cmd.ExecuteNonQuery(); // returns 1, temp table has not been created.
fails utterly.
Is there a proper reason for this or is it just another one of those things?