troubleshooting Question

Invalid column name in #temp table

Avatar of saoirse1916
saoirse1916Flag for United States of America asked on
Microsoft SQL Server
3 Comments1 Solution3035 ViewsLast Modified:
I've got a query that dumps data to a temp table, then uses a WHILE loop to update a field in that temp table.  When I execute the SQL in Query Analyzer everything runs just fine, but when I call the stored procedure I get "Invalid column name 'notificationGroupName'" pointing to the initial insert into the temp table.  I also get another of the same error pointing to my ORDER BY clause when I'm finally selecting all the data in the end.  Can anyone point me in the right direction?

ALTER PROCEDURE [dbo].[sproc_dashboard_select_notifications]
	@UserID int



CREATE TABLE #TempNotifications
	notificationID int,
	notificationDate datetime,
	notificationGroupName varchar(250),
	processStepID int,
	coID varchar(50),
	suiteID int,
	leaseID int,
	assetID int,
	woID int,
	notificationRelatesTo varchar(250)

--	Save all applicable notifications to a temp table
INSERT INTO #TempNotifications (notificationID, notificationDate, notificationGroupName, processStepID, coID, suiteID, leaseID, assetID, woID)
	SELECT notificationID, notificationDate, notificationGroupName, processStepID, coID, suiteID, leaseID, assetID, woID
	FROM tblNotifications
	JOIN tblNotificationGroupLevel ON tblNotifications.notificationGroupLevelID = tblNotificationGroupLevel.notificationGroupLevelID
	JOIN tblNotificationGroup ON tblNotificationGroupLevel.notificationGroupID = tblNotificationGroup.notificationGroupID
	WHERE tblNotifications.userID = @UserID AND notificationStatus = 0

FROM #TempNotifications
ORDER BY notificationDate ASC, notificationGroupName ASC


Open in new window

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros