declare @Topicid dtid Declare @LevelID varchar(10) select @Topicid = 'L10000' select @LevelID= substring(@Topicid,1,2) -- output - L1 select QID,Marks,Question from QBObjective where @LevelID+'SubjectID' = @TopicID -- FAIL --L1SubjectID is my column name //-- not giving any results, actually data is in table with specified id print @LevelID+'SubjectID' // output is L1SubjectID -------actual syntax select QID,Marks,Question from QBObjective where L1SubjectID = @TopicID -- Success
Please suggest me