I have three table
stype table,question table and the final table is fivesquestiondetails.
both the primay key id i have inserted in fivesquestiondetails table. Please check the my below store procedure code.
- CREATE PROCEDURE [dbo].[questionrecords]
- AS
- SET NOCOUNT ON
- BEGIN
- BEGIN TRY
- BEGIN
- select distinct q.question_name as 'Question',qd.question_option as 'Option',s.name from [dbo].[five_s_question] q inner join
- [dbo].[five_s_question_details] qd on q.id=qd.question_id inner join [dbo].[five_s_sitetype] s on s.id=qd.stype_id
- END
- END TRY
- BEGIN CATCH
- DECLARE @ErrorMessage VARCHAR(MAX);
- SELECT @ErrorMessage ='There was a problem trying to Retrieve Course Type'
- + Char(13) + Char(10) + 'The error was: ' + Char(13) + Char(10) + ERROR_MESSAGE()
- RAISERROR (@ErrorMessage, 16, 1)
- END CATCH
- END
three tables
[dbo].[five_s_sitetype]
id, name, cbu, doc, mbu, dom
[dbo].[five_s_question]
id, question_name, weightage, stype_id, cbu, doc, mbu, dom, qstatus
[dbo].[five_s_question_details]
id, question_id, question_option, details_weightage, stype_name, stype_id, cbu, doc, mbu, dom