views:

333

answers:

1

I'm accessing a stored procedure from ADO.NET. The stored procedure should eventually returns a single result set.

To compute this result, a temporary table is filled with a SELECT INTO statement.

The problem is that the result of the SELECT INTO statement is also returned as a result set to .NET.

Can this be suppressed? Or should I not use SELECT INTO, but CREATE TABLE followed by an INSERT statement?

+2  A: 

I would suggest avoiding SELECT INTO as it's going to infer your column names/types, and if your source query is in any way complex (such as CASE statements) this can produce unexpected results.

I always create either a table variable or a temp table if I need to hold values as described.

If you use CREATE TABLE #TableName () (or DECLARE @tableName TABLE ()) then use INSERT then you won't get the extra result set returned.

Timothy Walters