473,805 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The scripts in the store procedure run slowly, but quickly exec in the Query Analyzer

1 New Member
Hi,

When i call the procedure sp_jysczld_new from the Query Analyzer, it runs slowly.
But when i extract the sql scripts from the procedure sp_jysczld_new, it runs quickly.
Why? I don't understand.

store procedure sp_jysczld_new:
--------------------------------------------------
SET QUOTED_IDENTIFI ER OFF
GO
SET ANSI_NULLS OFF
GO

CREATE PROCEDURE sp_jysczld_new
@gs_userid CHAR(16),
@location char(10),
@pri char (10)
AS

SELECT Z.ORDER_NUM,ZI. ORDER_ITEM,Z.CU STOM_ID,ZI.PROD UCT_ID,ZI.PRODU CT_NAME,ZI.LENG TH,ZI.CDGC,ZI.H EIGHT,ZI.L_HEIG HT,ZI.U_HEIGHT, ZI.CATEGORY,ZI. COLOR_ID,ZI.SGQ TYS,ZI.plannum, ZI.totalwgt,
ZI.banglong,ZI. bangzs,ZI.qgzs ,ZI.BANG_GRADE, ZI.PRI, ZI.LOCATION,Z.E ND_DATE, ZI.NOTESZ AS NOTES--,ZI.MJCOUNT

INTO #Z

FROM ORDERZ Z INNER JOIN ORD_ITEMZ ZI ON Z.ORDER_ID=ZI.O RDER_ID

WHERE (ZI.over_work in ( 'A','B','D') ) AND ZI.PC_MODE = 'Y' and ZI.sgqtys > 0
AND (ZI.location = @location or @location = 'ALL')
AND (ZI.pri = @pri or @pri = 'ALL')
AND Z.order_num in ( select order_num from temp_order_id where username = @gs_userid)


drop table #Z


GO
SET QUOTED_IDENTIFI ER OFF
GO
SET ANSI_NULLS ON
GO
------------------------------------------------------

The scripts which i extract from the store procedure(the same as the store procedure):
---------------------------------------------------

declare @gs_userid char(16)
declare @location char(10)
declare @pri char(10)

set @gs_userid = 'mmm'
set @location = 'ALL'
set @pri = 'ALL'

SELECT Z.ORDER_NUM,ZI. ORDER_ITEM,Z.CU STOM_ID,ZI.PROD UCT_ID,ZI.PRODU CT_NAME,ZI.LENG TH,ZI.CDGC,ZI.H EIGHT,ZI.L_HEIG HT,ZI.U_HEIGHT, ZI.CATEGORY,ZI. COLOR_ID,ZI.SGQ TYS,ZI.plannum, ZI.totalwgt, ZI.banglong,ZI. bangzs,ZI.qgzs ,ZI.BANG_GRADE, ZI.PRI, ZI.LOCATION,Z.E ND_DATE, ZI.NOTESZ AS NOTES--,ZI.MJCOUNT

INTO #Z

FROM ORDERZ Z INNER JOIN ORD_ITEMZ ZI ON Z.ORDER_ID=ZI.O RDER_ID

WHERE (ZI.over_work in ( 'A','B','D') ) AND ZI.PC_MODE = 'Y' and ZI.sgqtys > 0
AND (ZI.location = @location or @location = 'ALL')
AND (ZI.pri = @pri or @pri = 'ALL')
AND Z.order_num in ( select order_num from temp_order_id where username = @gs_userid)
drop table #z

---------------------------------------------------
Sep 16 '06 #1
0 1681

Sign in to post your reply or Sign up for a free account.

Similar topics

7
9015
by: Bill Kellaway | last post by:
Hi there - this should be fairly simple for someone. Basically I can't figure out how to pass the parameters from ASP to a Stored Procedure on SQL. Here's my code: I just need to help in learning how to pass these varibables from ASP to the SP.
5
13279
by: Raj | last post by:
Hi all, Can anyone help me with a script which would delete files or move them to a different folder at some scheduled time..! Please.....!!! Thanks in advance...
5
7296
by: Warren Wright | last post by:
Hi group, I have a select statement that if run against a 1 million record database directly in query analyzer takes less than 1 second. However, if I execute the select statement in a stored procedure instead, calling the stored proc from query analyzer, then it takes 12-17 seconds. Here is what I execute in Query Analyzer when bypassing the stored procedure:
2
10393
by: Begoña | last post by:
in my java application I've made a call to this stored procedure CREATE procedure pruebaICM @pANI varchar(20), @pTABLA varchar(20), @pInsert varchar(500), @pUpdate varchar(1000), @pFLAG varchar(1), @pResultado int OUTPUT
1
1717
by: Witold Iwaniec | last post by:
Hi I have a procedure that calls a view. The view is built with some outer joins but it performs fine. If I run in Query Analyzer select count(*) from long_name_view where name_id = 'AAA'
2
2752
by: Crazy Cat | last post by:
Hi, I wrote the following in the SQL Server 2005 Express Management Studio Query Analyzer and hit execute. Even though Query Analyzer indicated success when I hit refresh on the stored procedure folder the procedure does not show up in the stored procedure list. When I entered 'exec Test' I get an error indicating that SQL Server 2005 can't find the procedure. I executed the following code 'select * from sys.all_objects where name like...
11
4382
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store procedure(assume there are many columns in the table). I need to insert data into two separate tables, the relation between these two tables is 1 row of data in table1 could have multiple rows in table2 related to table1, but if the data insertion into...
9
2472
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug through the application in Visual Studio .NET 2003 the application an exception when it executes the query.
1
1993
by: codefragment | last post by:
Hi I've heard 2 things recently, can I confirm if their true/false? (1) If you have a stored procedure and you want to optimise it you can call exec proc1, you could also use define/set for each of the variables and copy the code into query analyser, this then makes it easier to tune. However the optimiser works differently for these variables than it does for variables passed into the query via exec and will produce a less optimal
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.