我可以使用EXEC
关键字运行存储过程来填充QuestionScore
列吗?
CREATE TABLE Question_Result
(
ResultID INT IDENTITY (10000, 1) NOT NULL,
QResultID VARCHAR (10) NOT NULL DEFAULT 'QRES' + CAST(NEXT VALUE
FOR non_identity_incrementer AS VARCHAR(10)),
QuestionScore DECIMAL (4,2) EXEC dbo.update_question_result_question_score(),
Assessment INT NULL,
DateTimeModified DATETIME NOT NULL DEFAULT SYSDATETIME(),
PRIMARY KEY CLUSTERED (ResultID),
FOREIGN KEY (Assessment) REFERENCES Assessment_Result (ResultID)
);
我的存储过程是:
CREATE PROCEDURE update_question_result_question_score (
@QuestionScore DECIMAL(4,2) OUTPUT,
@StudentAnswer NVARCHAR(MAX) OUTPUT,
@AssessingAnswer NVARCHAR(MAX) OUTPUT
)
AS
BEGIN
SELECT *
FROM StudentAnswerQuestionScore
SET @QuestionScore = (SELECT Score FROM StudentAnswerQuestionScore)
SET @StudentAnswer = (SELECT [Student Answer] FROM StudentAnswerQuestionScore)
SET @AssessingAnswer = (SELECT [Assessing Answer] FROM StudentAnswerQuestionScore)
IF (@StudentAnswer = @AssessingAnswer)
INSERT INTO Question_Result (QuestionScore)
VALUES (@QuestionScore)
END
答案 0 :(得分:0)
您可以尝试使用计算列的函数。希望下面的代码可以给你一些想法:
fragments