Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Help with an if statement and coding

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-23 : 09:31:22
Anita writes "Hello,

I have the following code and the if statements do not seem to be working. I was wondering if someone can help me with this. I also would like to know if the code can be slimmed down a bit.

Thank you,
Anita

Declare @count as numeric

if (select REQUEST from TEST_REPORT.dbo.TEAM3B_PULL_TOTAL_TST) != (select REQUEST from TEST_REPORT.dbo.REQUEST_BUS_REQ_TST)
begin

Insert into TEST_REPORT.dbo.REQUEST_BUS_REQ_TST (request,business_req_id,bus_test,test_case_id,test_case_source,test_case_descr)
select distinct request,business_req_id,bus_test,test_case_id,test_case_source,test_case as test_case_description from TEST_REPORT.dbo.TEAM3B_PULL_TOTAL_TST
where request_close_date < (select getdate())
set @count = @count +1
end
Else

if (select REQUEST from TEST_REPORT.dbo.TEAM3B_PULL_TOTAL_TST) != (select REQUEST from TEST_REPORT.dbo.REQUEST_BUS_REQ_TST)
begin

Insert into TEST_REPORT.dbo.REQUEST_BUS_REQ_TST (request,business_req_id,bus_test,test_case_id,test_case_source,test_case_descr)
select request,business_req_id,bus_test,test_case_id,test_case_source,test_case as test_case_description
from TEST_REPORT.dbo.TEAM3B_PULL_TOTAL_TST
Order by REQUEST,BUSINESS_REQ_ID,TEST_CASE_ID
end

if (select REQUEST from TEST_REPORT.dbo.TEAM3B_PULL_TOTAL_TST) != (select REQUEST from TEST_REPORT.dbo.BUS_REQ_DESCRIPTION_TST)
begin
Insert into TEST_REPORT.dbo.BUS_REQ_DESCRIPTION_TST(request,business_req_id,source)
select distinct request,business_req_id,test_case_source as source from TEST_REPORT.dbo.TEAM3B_PULL_TOTAL_TST
where request_close_date < (select getdate())
set @count = @count +1
end
Else
begin
delete TEST_REPORT.dbo.RDD_UPDATE_TST
Insert into TEST_REPORT.dbo.RDD_UPDATE_TST(request,business_req_id,test_case_id,test_case_descr)
select distinct request,business_req_id,test_case_id,test_case_descr from TEST_REPORT.dbo.TEAM3B_PULL_TOTAL_TST
where request_close_date < (select getdate())
order by REQUEST,BUSINESS_REQ_ID,TEST_CASE_ID
end
"
   

- Advertisement -