Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
battler
Starting Member
1 Post |
Posted - 2012-01-04 : 23:14:04
|
I have a problem where a Stored Procedure works fine while in Query Analyser however when executed through a web server it appears fine but no records are being committed to the database. I have done this many times before successfully so I am not sure why now nothing is happening. I receive no error messages, the only possible difference this time is I am using a SELECT INTO statement within the procedure.Any suggestions would be appreciated, thanks in advance.The SP is included below:SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS OFF GOAlter PROCEDURE [dbo].[sp_courseAttendance] @lessonID smallInt, @csvAttendance varchar(4000)ASSET NOCOUNT Off IF OBJECT_ID ('tOldAttendance', 'U') IS NOT NULL DROP TABLE tOldAttendance; IF OBJECT_ID ('tNewAttendance', 'U') IS NOT NULL DROP TABLE tNewAttendance; DECLARE @memberID int --get old enrolment values into temp table SELECT memberID INTO tOldAttendance FROM tLessonAttendance WHERE lessonID = @lessonID SELECT value INTO tNewAttendance FROM [dbo].[fn_Split](@csvAttendance, ',') --value = memberID DECLARE attend_curs CURSOR FOR SELECT value FROM tNewAttendance -- value = memberID OPEN attend_curs FETCH NEXT FROM attend_curs INTO @memberID WHILE @@FETCH_STATUS = 0 BEGIN IF @memberID > 0 BEGIN SELECT memberID FROM tOldAttendance WHERE memberID = @memberID IF @@rowCount = 0 --NO PREVIOUS RECORD INSERT INTO tLessonAttendance ([LessonID], [MemberID]) VALUES(@lessonID, @memberID) END FETCH NEXT FROM attend_curs INTO @memberID END CLOSE attend_curs DEALLOCATE attend_curs --finally remove any attendance records that should not be there DELETE FROM tLessonAttendance WHERE LessonID = @lessonID AND MemberID =( SELECT memberID from tOldAttendance AS O WHERE NOT EXISTS ( SELECT value from tNewAttendance AS N WHERE O.memberID = n.value ) ) GO IF OBJECT_ID ('tOldAttendance', 'U') IS NOT NULL DROP TABLE tOldAttendance; GO IF OBJECT_ID ('tNewAttendance', 'U') IS NOT NULL DROP TABLE tNewAttendance; GOSET NOCOUNT ONGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GO |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|