Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 990097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:53:45+00:00 2026-05-16T05:53:45+00:00

I have created a stored procedure CREATE PROCEDURE GetCustomerWiseSales(@StartDate nvarchar(10), @EndDate nvarchar(10)) AS SELECT

  • 0

I have created a stored procedure

CREATE PROCEDURE GetCustomerWiseSales(@StartDate nvarchar(10), @EndDate nvarchar(10))
AS

SELECT C.cCode, min(C.cName) as Customer, sum(P.BeerValue) as BeerValue, sum(P.RestGroup)as RestGroup
from Customers C
Join
(
SELECT     Sales.CustomerID, SUM(SalesLog.Quantity * SalesLog.Price) as BeerValue, 0 RestGroup
FROM         Sales INNER JOIN
                  SalesLog ON Sales.MemoNo = SalesLog.MemoNo
WHERE     (pGroup=8 and pSize>500) and Sales.Billdate>=@StartDate and Sales.Billdate<=@EndDate
group by  Sales.CustomerID

union all

SELECT     Sales.CustomerID, 0 BeerValue,SUM(SalesLog.Quantity * SalesLog.Price) AS RestGroup
FROM         Sales INNER JOIN
                  SalesLog ON Sales.MemoNo = SalesLog.MemoNo
WHERE     (pGroup!=8) and Sales.Billdate>=@StartDate and Sales.Billdate<=@EndDate
group by  Sales.CustomerID
)P
on P.CustomerID=C.cCode 
group by C.cCode

this SP is working nicely in Management Studio and outputs results before I blink my eyes. But when I added this SP in C# App through Data Access Layer and previewed Data using TableAdapter preview window, in first run it took 8-10 seconds to show data, in second run Preview windows threw Time Out exception. I also added a new TableAdapter with regular SQL to confirm this issues but regular SQL GetData function is working nicely.

I don’t understand how a same procedure which is working nicely under same user-name and password in Management Studio, not working in DAL.

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:53:46+00:00Added an answer on May 16, 2026 at 5:53 am

    You should capture an execution plan of the stored procedure running under the DAL and compare it to the one running under Management Studio express – you can do this using Sql Server Profiler.

    Also make sure that you are running the stored procedure using exactly the same parameters (capture a trace of the procedure being executed from your DAL using Sql Server profiler and copy and paste the query into SQL server management studio)

    Finally (this is a shot in the dark) you might want to try parameter masking your inputs as I have found it to have some effect in the past:

    CREATE PROCEDURE GetCustomerWiseSales(@StartDate nvarchar(10), @EndDate nvarchar(10))
    AS
    
    DECLARE @MaskedStartDate NVARCHAR(10)
    SET @MaskedStartDate = @StartDate
    DECLARE @MaskedEndDate NVARCHAR(10)
    SET @MaskedEndDate = @EndDate 
    
    -- Rest of query with @StartDate replaced with @MaskedStartDate etc...
    

    I’ve seen this make all the difference in certain situations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created the following stored procedure.. CREATE PROCEDURE [dbo].[UDSPRBHPRIMBUSTYPESTARTUP] ( @CODE CHAR(5) ,
I have created a Stored Procedure, that looks like this: DELIMITER €€ CREATE PROCEDURE
I have created a stored procedure similar to this simplified example: CREATE PROCEDURE dbo.sp_MyStoredProcedure
I have created a stored procedure in mysql DELIMITER // CREATE PROCEDURE simpleproc ()
I have created a stored procedure in SQL Server 2005, also I create another
I have created a stored procedure for my report.. create Procedure [dbo].[sp_Score_Grade] @Month int,
I have already created a stored procedure for Select Query and it is working
If I have two trivial stored procedures, created like so: create procedure root as
I have this stored procedure: CREATE OR REPLACE PROCEDURE LIQUIDACION_OBTENER ( p_Cuenta IN NUMBER,
I have the fallowing stored procedure: CREATE PROCEDURE `get`(IN tb VARCHAR(50), IN id INTEGER)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.