Closed charmi2011 closed 5 months ago
Option 1: Syntax error - can't help with that - invalid syntax will result in an error
Option 2: As per error message, you can't combine the queries in that way - can't help with that.
Option 3: The pool is not guaranteed to return the same connection one after another. Therefore running them as 3 consecutive queries is not guaranteed to give you the behaviour you expect.
You will need to run this type of query in a transaction or over a stored procedure so that you can hold onto a single connection and make these queries over a guaranteed connection. Alternatively you can set the pool max to 1; though this still isn't guaranteed to work as connections could be closed and recreated between requests.
I want to fetch the estimated execution plan of a query using the MSSQL package using Nodejs. As per the document https://learn.microsoft.com/en-us/sql/t-sql/statements/set-showplan-xml-transact-sql?view=sql-server-ver16 If I set the SHOWPLAN_XML to ON before the query execution it will return the execution plan for that query and all other consecutive queries until the SHOWPLAN_XML is set back to OFF for that particular session.
I tried to add the same thing, unfortunately I am not able to retrieve the XML execution plan for the query even after setting the SHOWPLAN_XML as ON.
Expected behaviour:
Running query:
Query 1:
SET SHOWPLAN_XML ON
Query 2:select top(1) UUID from users where UUID is not null;
Query 3:SET SHOWPLAN_XML OFF
Should return the execution XML plan for the SELECT query, but instead returns the actual result for Select Query.
Configuration:
Here is the SAMPLE code file which will show multiple options I tried to make this work but wasn't successful. Can someone please check this and let me know what I am missing here.
Software versions