473,465 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Parameterized Query unexplainably slow

Hi,

I came across a very weird problem. I get a statement from a file, dump
the text into a sql command, add a sql parameter and run the query.
This lasts about 1 1/2 hours, compared to 2-3 minutes running the same
statement from within the sql query analyzer.

To get around this problem I added the following lines INTO the
statement file:
declare @param int
set @param = 20060411

using this, the statement lasts 2-3 minutes.

When using s sql parameter with the sql command the same statement
needs 1 1/2 hours. I added the parameter as follows:

cmd.Parameters.Add("@FromDate_SID", date.ToString(("yyyyMMdd")));
or
cmd.Parameters.Add("@FromDate_SID",
Convert.ToInt(date.ToString(("yyyyMMdd"))));

Both result in a duration of 1 1/2 hours.

Does anyone can give me a clue on this? I'm lost, and I am running out
of ideas.

Thanks in advance
Michael

Apr 12 '06 #1
1 1672
Hi,

What is the type of the parameter?
Why are you converting it to a string with such a uncommon format?
By the name of the field it seems that it's a date, not a string,
OTOH, you declare @param as an Int

I think you have some issues with the type of the data

post your query and the type of the column you compare with the parameter
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
<mi**********@dws.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
Hi,

I came across a very weird problem. I get a statement from a file, dump
the text into a sql command, add a sql parameter and run the query.
This lasts about 1 1/2 hours, compared to 2-3 minutes running the same
statement from within the sql query analyzer.

To get around this problem I added the following lines INTO the
statement file:
declare @param int
set @param = 20060411

using this, the statement lasts 2-3 minutes.

When using s sql parameter with the sql command the same statement
needs 1 1/2 hours. I added the parameter as follows:

cmd.Parameters.Add("@FromDate_SID", date.ToString(("yyyyMMdd")));
or
cmd.Parameters.Add("@FromDate_SID",
Convert.ToInt(date.ToString(("yyyyMMdd"))));

Both result in a duration of 1 1/2 hours.

Does anyone can give me a clue on this? I'm lost, and I am running out
of ideas.

Thanks in advance
Michael

Apr 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: gary b | last post by:
Hello When I use a PreparedStatement (in jdbc) with the following query: SELECT store_groups_id FROM store_groups WHERE store_groups_id IS NOT NULL AND type = ? ORDER BY group_name
8
by: deko | last post by:
I'm trying to open a Recordset based on a parameterized query. I'm kind of new to parameterized queries, so I'm sure I'm missing something simple. Set qdfs = db.QueryDefs Set qdf =...
2
by: deko | last post by:
Is it possible to build a parameterized query from another parameterized query? I've tried two variations of this and can't seem to get it to work (using DAO). Any suggestions welcome! I...
11
by: anony | last post by:
Hello, I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These...
2
by: JSheble | last post by:
After building a parameterized ADO query, is there a method or a statement where you could see the actual query, with the parameterized values included?? -- Using Opera's revolutionary e-mail...
5
by: darrel | last post by:
I'm tring to modify an existing DB connection/query into a parameterized one. But, in doing so, I get an error stating that I am not defining the variable I am using in the query. This is what I...
8
by: Roland Hall | last post by:
In Access you use "*" + + "*", + can be replaced with & Calling a parameterized query in Access requires % be used in place of *, however, all that I have read show dynamic SQL passed to Access: ...
1
by: TF | last post by:
This group came through for me last time so here we go again. My page shows paint colors, brand name, product code, etc in a gridview with the background matching the paint color. Several links on...
3
by: xlar54 | last post by:
Is there a way to see the exact SQL being generated from a parameterized query? I am using this technique but am getting some strange SQL errors during execution and I would like to see the final...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.