Below is a stored procedure i am working with and i am trying to drop
the yesno_holding table if it exists but how do i add it back? Meaning
i want it to drop if it exists but i want to add it back if it doesnt
exist. the reason why i have to drop it is because when i run the
stored procedure it creates mulitple rows with the values in them but
in my report it takes the top row and insert those values into the
report and i dont want that i want the new values at the bottom row to
be inserted so i need to know how to add the table back once i drop it.
Dont know the syntax that should go after the DROP TABLE yesno_holding;
line. Any ideas?
CREATE PROCEDURE sp_YesNo AS
IF EXISTS (SELECT * FROM yesno_holding )
DROP TABLE yesno_holding;
declare @scheyes int
declare @scheno int
declare @schemb int
declare @scheother int
declare @howyes int
declare @howno int
declare @howmb int
declare @howother int
declare @paaexplyes int
declare @paaexplno int
declare @paaexplmb int
declare @paaexplother int
set @scheyes = (select count(*) from ConstructionSurvey where sche=1)
set @scheno = (select count(*) from ConstructionSurvey where sche=2)
set @schemb =(select count (*) from ConstructionSurvey where sche =3)
set @scheother = (select count(*) from ConstructionSurvey where not
(sche in (1,2,3)))
set @howyes = (select count(*) from ConstructionSurvey where howwarr=1)
set @howno = (select count(*) from ConstructionSurvey where howwarr=2)
set @howmb =(select count (*) from ConstructionSurvey where howwarr =3)
set @howother = (select count(*) from ConstructionSurvey where not
(howwarr in (1,2,3)))
set @paaexplyes = (select count(*) from ConstructionSurvey where
paaexpl=1)
set @paaexplno = (select count(*) from ConstructionSurvey where
paaexpl=2)
set @paaexplmb =(select count (*) from ConstructionSurvey where paaexpl
=3)
set @paaexplother = (select count(*) from ConstructionSurvey where not
(paaexpl in (1,2,3)))
GO