我有2张桌子,StudentRegsitre&议程,
议程表有(AgendaId,MatirelId,InstructorId,ClassId, AddedDate,Semester,StartTime,EndTime,DaySchedule) StudentRegsitre(Id,AgendaId,UserId)
需要通过从ASP.NET C#传递studentId来检查学生的StartTime,EndTime,DaySchedule,classid,以检查studentRegsitre是否重叠 我试试这个:
GO
Create procedure [dbo].[SP_OverLappingExists] (@AgendaId uniqueidentifier ,@UserId uniqueidentifier )
As Begin
Declare @CurrentAgendaId uniqueidentifier;
declare @MatirelId uniqueidentifier;
declare @InstructorId uniqueidentifier;
declare @ClassId uniqueidentifier;
declare @Semester nchar(10);
declare @StartTime time(7);
declare @EndTime time (7);
declare @DaySchedule varchar(50);
declare @UserIdNew uniqueidentifier;
declare @AgendaIdNew uniqueidentifier;
if exists (SELECT @CurrentAgendaId = Agenda.AgendaId,@MatirelId= Agenda.MatirelId,
@InstructorId= Agenda.InstructorId,@ClassId= Agenda.ClassId,@Semester= Agenda.Semester,
@StartTime= Agenda.StartTime,@EndTime= Agenda.EndTime,@DaySchedule= Agenda.DaySchedule,
@UserIdNew= StudentReg.UserId, @AgendaIdNew= StudentReg.AgendaId
FROM Agenda INNER JOIN
StudentReg ON Agenda.AgendaId = StudentReg.AgendaId
where StudentReg.UserId = @UserId
)
begin
return 1
end
但在@currentAgendaId = Agenda.AgendaId附近有错误“'='附近的语法不正确” 有什么帮助,如果有更好的想法,请与我分享。
p.s:这是研究案例。
答案 0 :(得分:0)
EXISTS
查询不会返回任何列,因此您无法为变量指定列值。
这是使用星号指定所有列不会影响性能的一种情况。常见用法是:
if exists ( select * from ... )
相当于:
if exists ( select 42 from ... )