473,408 Members | 1,873 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,408 software developers and data experts.

URGENT! Never ending loop

4
Hi,

I have this following code which doesn't seem to ever stop running! Can you help please?

create table #results
(
col varchar(20),
col1 varchar(20),
Number float)


select distinct channeloftrade
into #COT
from pnownsite dos

create table #temp (col1 varchar(50))
insert into #temp values('Active')
insert into #temp values('Inactive')
insert into #temp values('Total')

insert into #results (col, col1)
select t.col1, c.channeloftrade
from #COT c
cross join #temp t
order by 2,1

declare @COT varchar(50)
create table #COT1 (col1 varchar(50))

-- Create list of COTs that we can delete as and when used in the loop
insert into #COT1
select *
from #COT

while exists (select top 1 * from #COT1)
begin

set @COT = (select top 1 * from #COT1)

declare @Active int, @Inactive int, @Total int

select @Active = count(*)
from
(
select distinct pd.uoid
from pnpricedifferential pd
join pnownproduct op on pd.product = op.uoid
join pnownsite os on op.site = os.uoid
where pd.active = 1
and os.channeloftrade = @COT

) as sq1

select @Inactive = count(*) - @Active
from
(
select distinct pd.uoid
from pnpricedifferential pd
join pnownproduct op on pd.product = op.uoid
join pnownsite os on op.site = os.uoid
where os.channeloftrade = @COT
) as sq1

select @Total = count(*)
from
(
select distinct pd.uoid
from pnpricedifferential pd
join pnownproduct op on pd.product = op.uoid
join pnownsite os on op.site = os.uoid
where os.channeloftrade = @COT
) as sq1


exec(
'update #results
set Number = '+@Active+'
where col = ''Active''
and col1 = '''+@COT+'''

update #results
set Number = '+@Inactive+'
where col = ''Inactive''
and col1 = '''+@COT+'''

update #results
set Number= '+@Total+'
where col = ''Total''
and col1 = '''+@COT+''''
)

delete #COT1 where col1 = @COT
end

select * from #results
order by 1,2

drop table #COT
drop table #COT1
drop table #results
drop table #temp
Dec 19 '07 #1
0 795

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

Similar topics

3
by: Rob | last post by:
I have a form - when you click the submit button, it appends a variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable) It also opens a new page. Now, that some_dynamic_variable is...
9
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY (for days) and MMYYYY (for months). The target...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
28
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
7
by: zeyais | last post by:
Here is my HTML: <style> ..leftcolumn{float:left;width:300px;border: 1px solid #ccc} ..rtcolumn{float:left;width:600px;border: 1px solid #ccc} </style> <body> <div class="leftcolumn"...
33
by: dembla | last post by:
Hey Frnds can anyone help me in this i need a program in 'c' PROGRAM to print NxN Matrix 9 1 8 1 2 3 2 7 3 as 4 5 6 6 4 5 7 8 9 in sorted form
8
by: ginnisharma1 | last post by:
Hi All, I am very new to C language and I got really big assignment in my work.I am wondering if anyone can help me.........I need to port compiler from unix to windows and compiler is written...
1
by: alok sengar | last post by:
hi, I have already tried this URL's code "http://www.java2s.com/Code/CSharp/Network/SimpleSNMP.htm" but I am getting error when i am creating a UDP type Socket and recieving packet from this...
7
by: Cirene | last post by:
I used to use the Web Deployment Project with my VS2005 projects. Now I've fully upgraded to VS2008. Do I have to download a new version of the Web Deployment Project? If so where can I find...
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
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
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
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
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...
0
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
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...

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.