473,511 Members | 15,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Store procedure and typed dataset

39 New Member
Hi. I need to create a new tableadapter retrieving data from DB using stored procedure.
When i wrote stored procedure script in the stored procedure wizard and click next(or finish) it's generate an error that it can not parse sql statment.
What do i need to change in the script to make it functional:
NOTE:stored procedure is fully functional in SQL SERVER 2005(calling from e.g. QA)


"
CREATE PROCEDURE dbo.spMDB_R_Chargeability_by_BDC
@Period DateTime,
@Type smallint
AS


DECLARE @MStart datetime, @MEnd datetime, @YStart datetime

SET @MStart = dbo.fnMDB_GetPeriodStart(@Period,@Type)
SET @MEnd = dbo.fnMDB_GetPeriodEnd(@Period,@Type)
SET @YStart = dbo.fnMDB_YearStart(@period)




SELECT MDB_V_Chargeability_BDC.[ID],


CASE SUM([A Sum])
WHEN NULL THEN 0
ELSE ROUND(SUM([C Sum]) / SUM([A sum]) * 100,2)
END as [C/A (%) (V)],

CASE SUM([A Sum])
WHEN NULL THEN 0
ELSE ROUND(SUM([M Sum]) / SUM([A Sum]) * 100,2)
END as [M/A (%) (V)],

SUM([C Sum]) as [C (V)],
SUM([M Sum]) as [M (V)],
SUM([A Sum]) as [A (V)],

CASE [A (Y)]
WHEN NULL THEN 0
ELSE ROUND([C (Y)] / [A (Y)] * 100,2)
END as [C/A (%) (Y)],

CASE [A (Y)]
WHEN NULL THEN 0
ELSE ROUND([M (Y)] / [A (Y)] * 100,2)
END as [M/A (%) (Y)],

[C (Y)], [M (Y)], [A (Y)]

FROM MDB_V_Chargeability_BDC

INNER JOIN
(SELECT [ID], ROUND(SUM([C sum]),2) as [C (Y)], ROUND(SUM([A sum]),2) as [A (Y)], ROUND(SUM([M sum]),2) as [M (Y)]
FROM MDB_V_Chargeability_BDC
WHERE MDB_Period >= @YStart and MDB_Period <= @period
GROUP BY [ID]
) as CHARGEABILITY_BY_YEAR on (CHARGEABILITY_BY_YEAR.[ID] = MDB_V_Chargeability_BDC.[ID])

WHERE
MDB_Period >= @MStart and MDB_Period <= @MEnd
GROUP BY MDB_V_Chargeability_BDC.[ID], [A (Y)],[C (Y)],[M (Y)]"
Jan 23 '07 #1
1 1327
kenobewan
4,871 Recognized Expert Specialist
Stored procedures are notoriously hard to debug. Well done for testing select statement in QA!

I suggest stripping the SP back to the bare essentials until it works and then building it up again until you receive an error. In my experience, inner joins often produce problems and issues with scalability - that would be my first target...

Hope that this helps.
Jan 24 '07 #2

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

Similar topics

1
1908
by: Peter Rilling | last post by:
To minimize database calls, I would like to have a single stored procedure return all the data necessary to display on my page. This information is related from several different tables and what I...
7
2206
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
6
2698
by: Jim | last post by:
Can someone, please, show me how to display the results of a stored procedure in a VB.NET datagrid on a winform? I'm a newbie. Here's my SQL 2000 stored precedure that returns the status of...
5
10610
by: moondaddy | last post by:
I'm caching a dataset in an asp.net session variable to hold a user's data. one data item I need to store is an image the user uploaded. My problem is that I don't know how to get the image into...
3
2735
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong...
1
9334
by: Optimus | last post by:
Hi everyone, I currently develop an application in vs.net 2005 with vb.net. I was trying to use typed dataset and I've got in trouble for converting untyped dataset into Typed DataSet. I don't...
3
4859
by: Jon B | last post by:
Hi There! I'm looking into Strongly Typed DataSets in the .NET Framework. I know it can generated strongly typed tables as objects and column names as properties. However, one thing that I...
7
2365
by: Pim75 | last post by:
Hello, I want to store multiple records at once in a SQL database with a For..Next instruction like the sample code below: For counter = 0 To 100 Dim dbInsert As New SqlCommand( _ "INSERT...
21
2391
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
0
7242
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
7138
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...
1
7075
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...
0
5662
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
4737
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
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.