2

In SSMS, are IntelliSense and SQLCMD mode mutually exclusive?

Is there any way to make IntelliSense work when SQLCMD mode is enabled? (I use SQLCMD a lot)

I'm trying to understand why IntelliSense becomes disabled in SQLCMD mode, but there's so much information for both of them in Google search results that I can't find an obvious answer.

I found this good discussion about it, but not really an answer to my question.

3

Enabling the "TSQL" XEvent Profiler session allows us to see when the Intellisense cache is refreshed.

When running in SQLCMD mode, SSMS doesn't even attempt to obtain the Intellisense data.

If you disable SQLCMD mode via the menu on a session that is already connected, while the TSQL XEvent Profiler is running, you'll see SSMS query the system schema for the relevant info.

Since SQLCMD mode can be used to connect to a different instance, having accurate information for Intellisense would be difficult to guarantee, which is likely why Microsoft has it turned off.

3
  • Ahhh I think I understand now. Because SQLCMD is a much larger sandbox with access to many resources, Intellisense wouldn't know what data to access or display?
    – spinjector
    Sep 1 at 18:28
  • precisely correct
    – Hannah Vernon
    Sep 1 at 18:32
  • 1
    Gotcha. Thank you. I'll mark this as the answer.
    – spinjector
    Sep 1 at 18:34
2

This article states that intellisense is turned off when in SQLCMD mode.

https://docs.microsoft.com/en-us/sql/ssms/scripting/troubleshooting-intellisense?view=sql-server-ver15

Doesnt really answer why, but since this seems pretty absolute it would indicate there is no way to enable it in sqlcmd mode. My hunch is that intellisense is an SSMS function and sqlcmd mode is effectively like going to command line. Same behaviour in Azure Data Studio.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.