How to Execute SQL Query Without Displaying Results

How to Execute SQL Query without Displaying results

Executing will return a recordset. It may have no rows of course but get a result

You can suppress rows but not the resultset with SET FMTONLY

SET FMTONLY ON
SELECT * FROM sys.tables

SET FMTONLY OFF
SELECT * FROM sys.tables

Never had a use for it personally though...

Edit 2018. As noted, see @deroby's answer for a better solution these days

How to execute SQL query without displaying results in Postgres

explain (analyze) will execute the statement but will not return the results (only the execution plan).

Quote from the manual:

With this option, EXPLAIN actually executes the query, and then displays the true row counts and true run time

So you can use:

explain (analyze)
select id
from trips
order by l_pickup <-> (select l_pickup
from trips
where id =605689)
limit 100000;

The runtime reported by that is the time on the server without sending the data to the client. It will also show you what the slowest part of the statement is.

How to execute query without displaying result?

In the options section (under Tools-->Options), go to Query Results-->SQL Server and either "Results to Grid" or "Results to Text".

There is an option box for "Discard results after execution". Click the box.

Now, open another query window and there are no results. I imagine that the results are still being returned from the server, so you have network latency. This should fix the memory problem, though.

You can solve the network latency problem by running SSMS on the same server as the engine.

Select query - how to show results while query is executing

This query will help you to see the first 20 rows without required to stop the query.You can use the order by statement before the OPTION hint which like as the below;

select *
from Table1
where Column1 = '12345'
OPTION ( FAST 20)

select *
from Table1
where Column1 = '12345'
order by Column1
OPTION ( FAST 20)

Also you can see this link for more detail FAST number_rows hint

Display query results without table line within mysql shell ( nontabular output )

--raw, -r

For tabular output, the “boxing” around columns enables one column value to be distinguished from another. For nontabular output (such as is produced in batch mode or when the --batch or --silent option is given), special characters are escaped in the output so they can be identified easily. Newline, tab, NUL, and backslash are written as \n, \t, \0, and \\. The --raw option disables this character escaping.

The following example demonstrates tabular versus nontabular output and the use of raw mode to disable escaping:

% mysql
mysql> SELECT CHAR(92);
+----------+
| CHAR(92) |
+----------+
| \ |
+----------+

% mysql --silent
mysql> SELECT CHAR(92);
CHAR(92)
\\

% mysql --silent --raw
mysql> SELECT CHAR(92);
CHAR(92)
\

From MySQL Docs



Related Topics



Leave a reply



Submit