I need to create a temp table in a sproc but I an getting a strange error.
---------------------------------------
CREATE PROCEDURE [dbo].[sp_UpdateTotalsAgePrecinct]
(
@fromAge as Integer, @toAge as Integer
)
AS
IF @toAge > 0
SELECT NCOACounty, NCOAPrecinct INTO #tmpPrecinctAge
FROM dbo.AllData
ELSE
SELECT NCOACounty, NCOACountyCode INTO #tmpPrecinctAge
FROM dbo.AllData
---------------------------------------
I get the error #tmpPrecinctAge is already an object. The error is on the line that starts after the else. If I take out the Else and last sql statement, I can save it fine, but as is above, I can save this.
---------------------------------------
CREATE PROCEDURE [dbo].[sp_UpdateTotalsAgePrecinct]
(
@fromAge as Integer, @toAge as Integer
)
AS
IF @toAge > 0
SELECT NCOACounty, NCOAPrecinct INTO #tmpPrecinctAge
FROM dbo.AllData
ELSE
SELECT NCOACounty, NCOACountyCode INTO #tmpPrecinctAge
FROM dbo.AllData
---------------------------------------
I get the error #tmpPrecinctAge is already an object. The error is on the line that starts after the else. If I take out the Else and last sql statement, I can save it fine, but as is above, I can save this.