Hi Im creating a Temp table and inserting data to the Table. Im going to use the Temp table to Join it to the specific User.
CREATE TABLE #MyTempTable
(
UsersId int,
ValautionCount int
)
SELECT
U.UserId,
COUNT(*) AS ValautionCount
INTO #MyTempTable
FROM
Users U
Right JOIN Valuation V ON V.ValuationUser = U.UserId
GROUP BY
U.UserId
DROP TABLE #MyTempTable
When I run this query I get this error : There is already an object named '#Temp' in the database.
But when I run this query DROP TABLE #MyTempTable
I get this error: Cannot drop the table '#Temp', because it does not exist or you do not have permission.
Im using SQL 2012