microsoft / vscode-mssql

Visual Studio Code SQL Server extension.
Other
1.55k stars 458 forks source link

When opening a large script, the extension doesn't recognize the file as a SQL file #960

Closed awtyler closed 3 years ago

awtyler commented 7 years ago

I get the error, "mssql: A SQL editor must have focus before executing this command" when trying to connect to my database after opening a large SQL file (5.4MB, but possibly smaller). VSCode recognizes the file as SQL (it says SQL in the blue bar at the bottom, where you can change the file Language mode), and if I copy/paste the contents of the file into a new file, it will execute. The problem only exists when opening an existing file that has a large file size when opened. The problem persists, even if an adequate amount of code is removed from the file, and the file is saved. You have to close and re-open the file to connect to a DB.

I was able to open and connect with a file that was 5.2MB with 15000 lines of code, but not one that was 5.4MB with 16,000 lines.

Steps to Reproduce:

  1. Open a large .sql file (mine was 5.4MB, 16,000 lines)
  2. Open the Command Pallete
  3. Choose "MS SQL: Connect"

The error is displayed before selecting a database connection.

sherwanikhans commented 7 years ago

adding The same issue is seen when executing large SQL query. And when 'cancel' feature is used to stop the query, the same error is seen and query still keeps running.

kevcunnane commented 7 years ago

Thanks for raising this. This is currently a limitation in VSCode which does minimal processing (colorization only, I believe) on larger files. This includes not sending information to our service that a file is open. I would recommend opening the issue in the VSCode github repository as it is definitely a blocker for SQL users with large files. This is much more common than in other languages such as Javascript or C#.

cristhiancastro commented 6 years ago

Hi, After install mssql extension, I'm trying to connect via "MS SQL: Connect" but I got same error (mssql: A SQL editor must have focus before executing this command). I'm not using large files, just my first time using this extension. I just wanna connect to SQLServer and get a simple tsql as: "select getdate()"

Thanks for you help.

sherwanikhans commented 6 years ago

Did you create/register the connection first?

On Dec 12, 2017 10:21 AM, "Cristhian Castro" notifications@github.com wrote:

Hi, After install mssql extension, I'm trying to connect via "MS SQL: Connect" but I got same error (mssql: A SQL editor must have focus before executing this command). I'm not using large files, just my first time using this extension. I just wanna connect to SQLServer and get a simple tsql as: "select getdate()"

Thanks for you help.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-mssql/issues/960#issuecomment-351083140, or mute the thread https://github.com/notifications/unsubscribe-auth/ARQ4XPj85ttNCCvWBlz9f6TNIbPT9PHZks5s_poHgaJpZM4OlS8z .

FrancescaDev commented 6 years ago

@sherwanikhans How do I create/register connection? I'm getting same error and also my first time trying to connect. Thank you :-)

FrancescaDev commented 6 years ago

@cristhiancastro Did you manage to resolve issue? I'm also trying to connect first time and unable to....:-/ Thank you :-)

FrancescaDev commented 6 years ago

@sherwanikhans I'm on mac os EL Capitan 10.11.6-unable to upgrade to Sierra. I installed HomeBrew and openssl via terminal and all seems fine- not very experienced in this yet :-) Thanks

kburtram commented 6 years ago

@FrankieLov this extension has a dependency on .Net Core 2.0, which unfortunately only supports macOS 10.12+ (according to https://docs.microsoft.com/en-us/dotnet/core/macos-prerequisites?tabs=netcore2x).

Sorry for the inconvenience. Out of curiosity, do you know why you can't upgrade to Sierra (incompatible hardware, other app compat issues, etc.)?

FrancescaDev commented 5 years ago

@kburtram Hi..I can't upgrade my os because the hardware is not compatible with Sierra - I have MacBook Pro 2009. I will have to learn more about dependencies ;-) I will have a look-thank you :-)

kburtram commented 3 years ago

Closing older issues without current repro reports. The colorization cut-off size is an upstream setting.