top button
Flag Notify
Site Registration

How to compile any query without executing it in sql server?

+2 votes
110 views
How to compile any query without executing it in sql server?
posted Jun 15, 2015 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

In sql server we can compile any sql server quires without executing it by setting the property NOEXEC.

Syntax:

SET NOEXEC {ON|OFF}
When It is set to on then if we execute any sql quries it will only compile it while if it is set to off then it will compile the sql quries as will execute it. Default is off. For example:

SET NOEXEC OFF
SELECT 'Exact Help'

Output:

Exact Help
When we will execute the above query first it will compile then execute it .

SET NOEXEC ON
SELECT 'Exact Help'

Output:

No output.
When we will execute the above query it will only compile.

Use of NOEXEC ON

  1. To check the synax of sql statements.
  2. To check the existance of objects.
  3. To debug the batch of quries.

Scope of NOEXEC property:

Scope of NOEXEC property is within a session. In other session we have to set the NOEXEC property once again.

Note:

When we login or open a new query page or tab we creates a new session in sql server.

answer Jun 18, 2015 by Manikandan J
...