473,725 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Internal SQL Server error when using variable

In the code below I get an Internal SQL Server error in Query
Analyzer. Ultimately I want to get thos code working in a function.

DECLARE @WeekNumber tinyint
DECLARE @Comp decimal(18,2)
DECLARE @PeriodFromDate datetime
DECLARE @PeriodToDate datetime

SET @WeekNumber = 27

SET @PeriodFromDate = (SELECT MIN(StartDate) AS StartDate FROM
Calendar WHERE WeekNumber = @WeekNumber)

SET @PeriodToDate = (SELECT MAX(EndDate) AS StartDate FROM Calendar
WHERE WeekNumber = @WeekNumber)

SET @Comp = (SELECT SUM(ActualGross Comp)
FROM dbo.fnc_Program LineUp_1_2()
WHERE Delay > 0
AND ClearanceCode <> 3
AND TeleCastDate BETWEEN @PeriodFromDate AND PeriodToDate)
But this code runs fine:
DECLARE @WeekNumber tinyint
DECLARE @Comp decimal(18,2)
DECLARE @PeriodFromDate datetime
DECLARE @PeriodToDate datetime

SET @WeekNumber = 27

SET @PeriodFromDate = (SELECT MIN(StartDate) AS StartDate FROM
Calendar WHERE WeekNumber = @WeekNumber)

SET @PeriodToDate = (SELECT MAX(EndDate) AS StartDate FROM Calendar
WHERE WeekNumber = @WeekNumber)

SELECT SUM(ActualGross Comp)
FROM dbo.fnc_Program LineUp_1_2()
WHERE Delay > 0
AND ClearanceCode <> 3
AND TeleCastDate BETWEEN @PeriodFromDate AND PeriodToDate
The only difference is that here I'm not setting @Comp to the return
value of the SELECT. This code also runs fine when I sum other
columns. Any ideas?
Jul 20 '05 #1
2 1797
I didn't actually try this but it looks like you want this instead:

SELECT @Comp = SUM(ActualGross Comp)
FROM dbo.fnc_Program LineUp_1_2()
WHERE Delay > 0
AND ClearanceCode <> 3
AND TeleCastDate BETWEEN @PeriodFromDate AND PeriodToDate

Instead of trying to select into a set statement you simply use the select
statement to set your own variable.

Best,
Muhd
"Carl Ganz" <se************ @verizon.net> wrote in message
news:a1******** *************** ***@posting.goo gle.com...
In the code below I get an Internal SQL Server error in Query
Analyzer. Ultimately I want to get thos code working in a function.

DECLARE @WeekNumber tinyint
DECLARE @Comp decimal(18,2)
DECLARE @PeriodFromDate datetime
DECLARE @PeriodToDate datetime

SET @WeekNumber = 27

SET @PeriodFromDate = (SELECT MIN(StartDate) AS StartDate FROM
Calendar WHERE WeekNumber = @WeekNumber)

SET @PeriodToDate = (SELECT MAX(EndDate) AS StartDate FROM Calendar
WHERE WeekNumber = @WeekNumber)

SET @Comp = (SELECT SUM(ActualGross Comp)
FROM dbo.fnc_Program LineUp_1_2()
WHERE Delay > 0
AND ClearanceCode <> 3
AND TeleCastDate BETWEEN @PeriodFromDate AND PeriodToDate)
But this code runs fine:
DECLARE @WeekNumber tinyint
DECLARE @Comp decimal(18,2)
DECLARE @PeriodFromDate datetime
DECLARE @PeriodToDate datetime

SET @WeekNumber = 27

SET @PeriodFromDate = (SELECT MIN(StartDate) AS StartDate FROM
Calendar WHERE WeekNumber = @WeekNumber)

SET @PeriodToDate = (SELECT MAX(EndDate) AS StartDate FROM Calendar
WHERE WeekNumber = @WeekNumber)

SELECT SUM(ActualGross Comp)
FROM dbo.fnc_Program LineUp_1_2()
WHERE Delay > 0
AND ClearanceCode <> 3
AND TeleCastDate BETWEEN @PeriodFromDate AND PeriodToDate
The only difference is that here I'm not setting @Comp to the return
value of the SELECT. This code also runs fine when I sum other
columns. Any ideas?

Jul 20 '05 #2
Thanks for the feedback. Your solution did work. Microsoft tech
support believes my initial problem to be a bug and suggested
INSERTING into an in-memory table.

Thanks

Carl Ganz

"Muhd" <ea*@joes.com > wrote in message news:<pQ_5d.546 211$gE.52683@pd 7tw3no>...
I didn't actually try this but it looks like you want this instead:

SELECT @Comp = SUM(ActualGross Comp)
FROM dbo.fnc_Program LineUp_1_2()
WHERE Delay > 0
AND ClearanceCode <> 3
AND TeleCastDate BETWEEN @PeriodFromDate AND PeriodToDate

Instead of trying to select into a set statement you simply use the select
statement to set your own variable.

Best,
Muhd
"Carl Ganz" <se************ @verizon.net> wrote in message
news:a1******** *************** ***@posting.goo gle.com...
In the code below I get an Internal SQL Server error in Query
Analyzer. Ultimately I want to get thos code working in a function.

DECLARE @WeekNumber tinyint
DECLARE @Comp decimal(18,2)
DECLARE @PeriodFromDate datetime
DECLARE @PeriodToDate datetime

SET @WeekNumber = 27

SET @PeriodFromDate = (SELECT MIN(StartDate) AS StartDate FROM
Calendar WHERE WeekNumber = @WeekNumber)

SET @PeriodToDate = (SELECT MAX(EndDate) AS StartDate FROM Calendar
WHERE WeekNumber = @WeekNumber)

SET @Comp = (SELECT SUM(ActualGross Comp)
FROM dbo.fnc_Program LineUp_1_2()
WHERE Delay > 0
AND ClearanceCode <> 3
AND TeleCastDate BETWEEN @PeriodFromDate AND PeriodToDate)
But this code runs fine:
DECLARE @WeekNumber tinyint
DECLARE @Comp decimal(18,2)
DECLARE @PeriodFromDate datetime
DECLARE @PeriodToDate datetime

SET @WeekNumber = 27

SET @PeriodFromDate = (SELECT MIN(StartDate) AS StartDate FROM
Calendar WHERE WeekNumber = @WeekNumber)

SET @PeriodToDate = (SELECT MAX(EndDate) AS StartDate FROM Calendar
WHERE WeekNumber = @WeekNumber)

SELECT SUM(ActualGross Comp)
FROM dbo.fnc_Program LineUp_1_2()
WHERE Delay > 0
AND ClearanceCode <> 3
AND TeleCastDate BETWEEN @PeriodFromDate AND PeriodToDate
The only difference is that here I'm not setting @Comp to the return
value of the SELECT. This code also runs fine when I sum other
columns. Any ideas?

Jul 20 '05 #3

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

Similar topics

1
2143
by: j-marvin | last post by:
hi- with the keyfocus webserver using php i get this error. "Internal Server Error", 500 error when using a CGI request http://www.keyfocus.net/kfws/faq/faqcommonproblems.php#PROBLEM5a There are many reason why a CGI request could fail, it could be that the CGI Filter is not properly configured or the CGI application itself has
5
8478
by: Ben | last post by:
hi when I try to excecute an ASP (either JS or VB) script to say, access a database record, I get an Internal Server Error HTTP 500.100 Why? and HOW CAN I FIX THIS? Thanks
6
3505
by: AlanS | last post by:
I have used Visual Studio for about 8 months. I have developed some ASP solutions. I had to get on with some other things and have not worked with ASP.NET for a couple months. In the meantime, I have upgraded to .NET Framework 200 V1.1. Over the week end I had to go back to work on a project that needed some changes. I get the following error when I try to open an existing project or create a new one. I have XP Professional An error...
8
10012
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500 Internal Server Error'."
4
6209
by: jf li | last post by:
I have a Asp.net web application and a Asp.net Web service application. The Web application is using HtmlInputFile to get a 50M size of file selected by end user, read the data of this file and pass the data to the web service. I already modified both web.config files and changed maxRequestLength to 60000(kb). When I debug the upload process, it seems the Web application can get the 50M file and read the data without problem, but when the...
11
12314
by: Lieven | last post by:
Hey, I had a hard disc problem last week on my server. I replaced the disc and copied al the files to the new hard disc, everything works fine again except some php scripts that are using the mail() function. When executing these scripts I get this error: "500 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.
9
2163
by: JT | last post by:
Here is the overall structure I will be referring to: End-program ProvideWorkFlow.dll Forms and methods that properly manipulate calls to methods in AccessUtils AccessUtils (a web service) Hide.dll methods and data I want to remain hidden I have a DLL, Hide.dll, that contains methods that I want to handle for
16
27901
Frinavale
by: Frinavale | last post by:
The following article is directed at people who are experiencing an HTTP/1.1 500 Internal Server Error while using Visual Studio 2003. The error message typically sounds something like: The web server reported the following error when attempting to create or open the Web Project located at the Following URL:http://localhost/Webapplication1’.HTTP/1.1 500 Internal Server Error’. This error tends to rear it's ugly head when you're creating...
3
5954
by: guillaume.braux | last post by:
Hello, I am running WS2008 + IIS7 + FASTCGI + ZendCore. I have not modified the default ZendCore php.ini configuration file. Actualy, any kind of PHP error, warning or notice gives me immediately a IIS 500 Error (Internal Server Error). It is a good thing in production environnement. For debuging purposes, I want temporary to be able to see PHP warnings and errors embedded on the html page.
0
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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
9257
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
9176
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
9113
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...
1
6702
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
6011
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();...
1
3221
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 we have to send another system
2
2635
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.