Wednesday, March 21, 2012

multiple where clauses

Hello helpful people :)

I have this sproc.

ALTER PROCEDURE

dbo.cis_UpdateCourseUserWithGrade

@.Grade

nvarchar,

@.UaaStudentId

nchar,

@.CourseId

int

AS

UPDATEcis_CourseUserSETGrade =@.GradeWHEREUaaStudentId = @.UaaStudentId

AND WHERE CourseID = @.CourseId

RETURN

the ANE WHERE isn't much liked. How can I update the field with the grade where both of the conditions are true? I'm getting an invalid syntax near @.UaaStudentId

Thanks.

ALTER PROCEDURE

dbo.cis_UpdateCourseUserWithGrade

@.Gradenvarchar,
@.UaaStudentIdnchar,
@.CourseId int

AS

UPDATEcis_CourseUserSETGrade =@.GradeWHEREUaaStudentId = @.UaaStudentId AND CourseID = @.CourseId

RETURN

In other words, don't repeat the word WHERE.

|||

Mikesdotnetting:

ALTER PROCEDURE

dbo.cis_UpdateCourseUserWithGrade

@.Gradenvarchar,
@.UaaStudentIdnchar,
@.CourseId int

AS

UPDATEcis_CourseUserSETGrade =@.GradeWHEREUaaStudentId = @.UaaStudentId AND CourseID = @.CourseId

RETURN

In other words, don't repeat the word WHERE.

thanks a million

|||I would also recommend defining the size for the parameters @.Grade and @.UaaStudentId. If you dont specify a size SQL uses the default size (I am making a wild guess its around 32) so if you send in a value anything more than that it could get truncated.|||

Big Smile Could you mark my post as the answer, please?

No comments:

Post a Comment