Click here to Skip to main content
15,944,832 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
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


When i attach it to a Function Import it is saying "The selected procedure returns no columns", but i'm returning data at MSMQ
Posted
Comments
Rohit Shrivastava 5-Nov-12 15:25pm    
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.
snsrkrishna 6-Nov-12 13:38pm    
thank you, working

1 solution

Placing answer from comments:

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.


Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900