Here is my SP alter PROCEDURE PopulateAllObjectiveQuestionsByTopic @TopicID dtid as SET NOCOUNT on begin Declare @LevelID varchar(10) select @LevelID = substring(@TopicID,1,2) declare @SQLString varchar(max) select @SQLString = 'select QID,Marks,Question from QBObjective where '+@LevelID+'SubjectID='''+@TopicID+'''' exec (@SQLString) end When i exeute at SQL i'm returning data but not at EF, is there any thing wrong with my SQL or approch
Quote:Instead of executing dynamic query write a static query with param, change to following select QID,Marks,Question from QBObjective where CASE WHEN @LevelID = 1 THEN 1SubjectID WHEN @LevelID=2 THEN 2SubjectID END = @TopicID I am sure you have limited number of Level as these are referring columns.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)