I have searched TempDB, there is no sign of my two temp tables. I have tried dropping them, it says they do not exist in the system catalog. I have turned off the PC overnight, what else could kill the thread??? I am still getting the message that they exist when I try to alter the procedure.
Just as a note: I *can* execute the proc. That works. I just can't alter it.
Please, I am way stuck here. I don't want to keep having to rename my tables to retest the proc.
Just in case it is my Proc that is the issue, here it is:
ALTER PROCEDURE spFindPub
@author varchar(20) = NULL,
@year smallint = NULL,
@inter bit = NULL,
@intra bit = NULL,
@inactive bit = NULL,
@program int = NULL
AS
DECLARE @authorid bigint
BEGIN TRAN
IF @program is NULL
BEGIN
SELECT PublicationID
INTO #PubProg
FROM tb_Publication
END
If @program is NOT NULL
BEGIN
SELECT PublicationID,
Program =
(SELECT Program
FROM vwPrograms
WHERE vwPrograms.ProgramID = tb_PublicationProgram.ProgramID)
INTO #PubProg
FROM tb_PublicationProgram
WHERE ISNULL(tb_PublicationProgram.ProgramID,'') = CASE
WHEN @program is NULL THEN ISNULL(tb_PublicationProgram.ProgramID,'')
ELSE @program END
END
If @@error <> 0
begin
RAISERROR 50000 'Error selecting Program info.'
ROLLBACK TRAN
GOTO end_of_batch
end
IF @author is NULL
BEGIN
SELECT tb_Publication.PublicationID
INTO #PubAuthor
FROM tb_Publication
END
IF @author is NOT NULL
BEGIN
SELECT tb_PublicationAuthor.PublicationID
INTO #PubAuthor
FROM tb_PublicationAuthor
INNER JOIN tb_Author ON
tb_PublicationAuthor.AuthorID = tb_Author.AuthorID
WHERE ISNULL(tb_Author.AuthorName,'') LIKE CASE
WHEN @author is NULL THEN ISNULL(tb_Author.AuthorName,'')
ELSE @author END
END
If @@error <> 0
begin
RAISERROR 50000 'Error selecting Author info.'
ROLLBACK TRAN
GOTO end_of_batch
end
SELECT
tb_Publication.PublicationID,
tb_Publication.Title,
tb_Publication.PubYear,
tb_Publication.Journal,
#PubProg.Program,
ProgramInvolvement = CASE
WHEN InterProgramatic = 1 THEN 'Inter'
WHEN IntraProgramatic = 1 THEN 'Intra'
ELSE ' ' END
FROM
tb_Publication
LEFT JOIN #PubProg ON
#PubProg.PublicationID = tb_Publication.PublicationID
WHERE
tb_Publication.PublicationID in
(SELECT #PubProg.PublicationID FROM #PubProg)
AND
tb_Publication.PublicationID in
(SELECT #PubAuthor.PublicationID FROM #PubAuthor)
AND
ISNULL(PubYear,'') = CASE
WHEN @year is NULL THEN ISNULL(PubYear,'')
ELSE @year END
AND
ISNULL(InterProgramatic,'') = CASE
WHEN @inter is NULL THEN ISNULL(InterProgramatic,'')
ELSE @inter END
AND
ISNULL(IntraProgramatic,'') = CASE
WHEN @intra is NULL THEN ISNULL(IntraProgramatic,'')
ELSE @intra END
AND
ISNULL(Inactive,'') = CASE
WHEN @inactive is NULL THEN ISNULL(Inactive,'')
ELSE @inactive END
ORDER BY tb_Publication.PublicationID
If @@error <> 0
begin
RAISERROR 50000 'Error selecting Publication'
ROLLBACK TRAN
GOTO end_of_batch
end
DROP TABLE #PubAuthor
DROP TABLE #PubProg
COMMIT TRAN
end_of_batch: