473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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(ActualGrossComp)
FROM dbo.fnc_ProgramLineUp_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(ActualGrossComp)
FROM dbo.fnc_ProgramLineUp_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 1787
I didn't actually try this but it looks like you want this instead:

SELECT @Comp = SUM(ActualGrossComp)
FROM dbo.fnc_ProgramLineUp_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.google.c om...
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(ActualGrossComp)
FROM dbo.fnc_ProgramLineUp_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(ActualGrossComp)
FROM dbo.fnc_ProgramLineUp_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.546211$gE.52683@pd7tw3no>...
I didn't actually try this but it looks like you want this instead:

SELECT @Comp = SUM(ActualGrossComp)
FROM dbo.fnc_ProgramLineUp_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.google.c om...
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(ActualGrossComp)
FROM dbo.fnc_ProgramLineUp_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(ActualGrossComp)
FROM dbo.fnc_ProgramLineUp_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
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 ...
5
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
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...
8
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...
4
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...
11
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...
9
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)...
16
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.