我在数据库中有 3 个表,1 个是瑜伽课,另一个是成员以及它们之间的交集,我想创建一个存储过程,该过程将打印指定类的详细信息以及分配给班级。报告输出的格式应与以下内容相同:
YOGA CLASS REPORT:
___________________
Class ID: 1112
Week day: Monday [Time: 07:00:00]
Studio Number: 1
No. Member Name Contact Number
________________________________________
1 John Doe +26 83 562 3953
到目前为止,我有:
CREATE PROCEDURE sp_Report
@classID SMALLINT
AS
IF NOT EXISTS(SELECT * FROM class WHERE classID = @classID)
BEGIN
RAISERROR ('classID does not exist',16,1)
RETURN
END
DECLARE @classWeekday VARCHAR(15)
DECLARE @classTime TIME
DECLARE @classStudioNo TINYINT
SELECT @classWeekday = class.classWeekday, @classTime = class.classTime,
@classStudioNo = class.classStudioNo
FROM class
WHERE @classID = classID
PRINT 'YOGA CLASS REPORT'
PRINT 'Class code:' +CAST(@classID AS VARCHAR)
PRINT 'Week day:' +@classWeekday +'[Time:' + CAST(@classTime AS VARCHAR)+ ']'
PRINT 'Studio Number' +CAST(@classStudioNo AS VARCHAR)
我现在如何打印参加特定课程的所有成员?任何帮助将不胜感激。