Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Invalid Column Name error
Message
From
10/11/2010 20:32:17
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Invalid Column Name error
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01488773
Message ID:
01488773
Views:
105
Hi,

Was hopiing someone could see why I get this message
Msg 207, Level 16, State 1, Line 8
Invalid column name 'MMMMM'.

(1 row(s) affected)
This is my stored procedure, and the 'MMMMM' is what I passing in as the second parameter.
ALTER PROCEDURE [dbo].[AppointmentsSelectByTutorsAndStudentID]
(
	@TutorIDs varchar(500),
	@StudentID char(5)
)
AS
BEGIN
	SET NOCOUNT ON;
	DECLARE @SQL varchar(600)
	
	SET @SQL = 'SELECT 
		AppointmentID,
		TutorID,
		Description
	FROM [dbo].[Appointment]
	WHERE 
		TutorID IN (' + @TutorIDs + ') OR
		AppointmentID IN (SELECT AppointmentID FROM StudentAppointments WHERE StudentID = ' + @StudentID + ')' 
	EXEC(@SQL)
END
Here is the window when it runs
USE [StudAthl]
GO

DECLARE	@return_value int

EXEC	@return_value = [dbo].[AppointmentsSelectByTutorsAndStudentID]
		@TutorIDs = N'10101, 30303',
		@StudentID = N'MMMMM'

SELECT	'Return Value' = @return_value

GO
Timothy Bryan
Next
Reply
Map
View

Click here to load this message in the networking platform