TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
baskaran chellasamy
NA
114
151k
what is the error
Dec 28 2012 12:36 AM
Hi friends
This is my query
ALTER procedure [dbo].[sp_getmarkforclass](@classid int,@examid int)
as
begin
declare @paramlist varchar(max),@query nvarchar(max)
set @paramlist=STUFF((select distinct ',[' + SubjectId + ']' from School.dbo.Mark_details where classid=@classid and ExamId=@examid for xml path('')),1,1,'')
print @paramlist
set @query='select * from(select '+ @paramlist +' from School.dbo.Mark_details) p PIVOT(sum(MarkObtained)for SubjectId IN ('+@paramlist+')) AS pvt'
exec @query
end
GO
and the error is
Msg 203, Level 16, State 2, Procedure sp_getmarkforclass, Line 8
The name 'select * from(select [23011],[23012],[23013],[23014],[23015] from School.dbo.Mark_details) p PIVOT(sum(MarkObtained)for SubjectId IN ([23011],[23012],[23013],[23014],[23015])) AS pvt' is not a valid identifier.
Reply
Answers (
2
)
When to use Primary key and Unique key
Retrieving pictures in bulk using SQL server 2005