Friday, December 6, 2013

T-SQL: Silent Select

Here is the solution I found on SO in its simplest form:

SELECT SomeField
INTO #tmpDevNull
FROM some_table

This will store the selected result in a temporary table that will simply be disposed at the end of the request.

You might also want to begin with:

SET NOCOUNT ON

So no "rows affected" message is shown.