Showing posts with label execution. Show all posts
Showing posts with label execution. Show all posts

Sunday, March 25, 2012

ActiveX Scritping was not able to initialize the script execution

I get this error ActiveX Scritping was not able to initialize the script
execution engine
Whenever a VBScripts is exe agaist SQL Server. The oddity is all works under
my NT account fine. Use anybody elses account or our service account it will
not work and you recieve the message above.
any ideas?A google search on the error came back with many hits. See if this helps...
http://www.sqldts.com/default.aspx?224
"jG" <jG@.discussions.microsoft.com> wrote in message
news:E82F512F-E180-429D-9BC5-2E9290B4DDE9@.microsoft.com...
> I get this error ActiveX Scritping was not able to initialize the script
> execution engine
> Whenever a VBScripts is exe agaist SQL Server. The oddity is all works
under
> my NT account fine. Use anybody elses account or our service account it
will
> not work and you recieve the message above.
> any ideas?

Sunday, February 12, 2012

Accessing query execution plan results programmatically

Does anyone know if it is possible to access the execution plan results programmatically through a stored procedure or .NET assembly? I have the code sample

SET SHOWPLAN_XML ON; query... SET SHOWPLAN_XML OFF;

but it can only be run from the interface. I have tried a couple of solutions including dynamic sql to try to capture the results in a variable or file with no luck.

Does anyone know of a way to programmatically capture this information? We are doing some research with distributed query processing of dynamically generated queries using multiple processing nodes, and it would be helpful to know an estimate of how large the query is before sending it away to be processed.

I have looked at the dm_exec_query_stats view; but it can only be run on a query that has already been executed. I need to know the execution plan before the query is executed. If there is a way to get a query to show up in this view without being executed, then that would work as well.

Thanks -- MT

C# sample

SqlConnectionStringBuilder connString = new SqlConnectionStringBuilder();
connString.ApplicationName = "TryIt";
connString.DataSource = @."(local)";
connString.IntegratedSecurity = true;
connString.InitialCatalog = "tempdb";
using (SqlConnection conn = new SqlConnection(connString.ToString()))
{
conn.Open();
SqlCommand showplan_on_cmd = new SqlCommand("set showplan_xml on", conn);
showplan_on_cmd.ExecuteNonQuery();
SqlCommand cmd = new SqlCommand("Select count(*) From sys.tables", conn);
using (SqlDataReader showplan_results = cmd.ExecuteReader())
{
if (showplan_results.Read())
{
Console.WriteLine(showplan_results[0].ToString());
}
}
SqlCommand showplan_off_cmd = new SqlCommand("set showplan_xml off", conn);
showplan_on_cmd.ExecuteNonQuery();
}

Hope that helps.

PS: You can use this sample inside a .NET assembly with slight modifications (use a context-connection) to do the same thing inside a stored procedure.

|||That worked great. I had tried an ExecuteDataSet operation, but I had not thought to try a data reader. Thanks!

Accessing Query Execution Plan (QEP) Statistics

Hi,
I have some questions about estimated QEPs that can be generated in MSSQL QA.
If I point at an icon/physical operator in the estimated QEP, it shows me
some statistics about the operator.
1. Is there a way to retrieve these statistics through a query, i.e., can
these statistics be available to the user?
2. Are these statistics generated at the server or at the client?
3. Also, is there a way to generate these statistics on my own?
Thanks in advance,
-TC.
T Chaudhary wrote:
> Hi,
> I have some questions about estimated QEPs that can be generated in
> MSSQL QA.
> If I point at an icon/physical operator in the estimated QEP, it
> shows me some statistics about the operator.
> 1. Is there a way to retrieve these statistics through a query, i.e.,
> can these statistics be available to the user?
> 2. Are these statistics generated at the server or at the client?
> 3. Also, is there a way to generate these statistics on my own?
> Thanks in advance,
> -TC.
Generated on the server. You can use SET SHOWPLAN_ALL ON from QA to get
results back in result set format.
Try This:
Set showplan_all on
go
select * from pubs..publishers
go
Set showplan_all off
go
David G.
|||If you are also interested in index statistics try
DBCC show_statistics(object_id, indid)
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"T Chaudhary" <replysoon_04@.yahoo.com> wrote in message
news:e8149671.0409091256.56631cf@.posting.google.co m...
> Hi,
> I have some questions about estimated QEPs that can be generated in MSSQL
QA.
> If I point at an icon/physical operator in the estimated QEP, it shows me
> some statistics about the operator.
> 1. Is there a way to retrieve these statistics through a query, i.e., can
> these statistics be available to the user?
> 2. Are these statistics generated at the server or at the client?
> 3. Also, is there a way to generate these statistics on my own?
> Thanks in advance,
> -TC.

Accessing Query Execution Plan (QEP) Statistics

Hi,
I have some questions about estimated QEPs that can be generated in MSSQL QA.
If I point at an icon/physical operator in the estimated QEP, it shows me
some statistics about the operator.
1. Is there a way to retrieve these statistics through a query, i.e., can
these statistics be available to the user?
2. Are these statistics generated at the server or at the client?
3. Also, is there a way to generate these statistics on my own?
Thanks in advance,
-TC.T Chaudhary wrote:
> Hi,
> I have some questions about estimated QEPs that can be generated in
> MSSQL QA.
> If I point at an icon/physical operator in the estimated QEP, it
> shows me some statistics about the operator.
> 1. Is there a way to retrieve these statistics through a query, i.e.,
> can these statistics be available to the user?
> 2. Are these statistics generated at the server or at the client?
> 3. Also, is there a way to generate these statistics on my own?
> Thanks in advance,
> -TC.
Generated on the server. You can use SET SHOWPLAN_ALL ON from QA to get
results back in result set format.
Try This:
Set showplan_all on
go
select * from pubs..publishers
go
Set showplan_all off
go
David G.|||If you are also interested in index statistics try
DBCC show_statistics(object_id, indid)
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"T Chaudhary" <replysoon_04@.yahoo.com> wrote in message
news:e8149671.0409091256.56631cf@.posting.google.com...
> Hi,
> I have some questions about estimated QEPs that can be generated in MSSQL
QA.
> If I point at an icon/physical operator in the estimated QEP, it shows me
> some statistics about the operator.
> 1. Is there a way to retrieve these statistics through a query, i.e., can
> these statistics be available to the user?
> 2. Are these statistics generated at the server or at the client?
> 3. Also, is there a way to generate these statistics on my own?
> Thanks in advance,
> -TC.