Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 21st, 2008, 11:06 AM
Authorized User
Join Date: Dec 2005
Location: , Colorado, USA.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rdove84
Default Stored Procedure not saving to database


I have a log in web application that is passing an id field to a stored procedure where the log in or log out time is captured and then saved to a database. In the query analyzer everything in the stored procedure pasted below comes out the way that it should but the results are only partially being saved to the database. It will save the id and the log in time but nothing else. If I play with the '@' symbol in the Update statements I can get the log in statement to save but then it overwrites all the log out times. If you are able to see the error(s) in my logic or the problem could you please point me in the direction of how to fix it?

    @id char (10)

    DECLARE @IsUpdate int
    DECLARE @totalHour float
    DECLARE @totalMinute float
    DECLARE @totalSecond float

    DECLARE @logIn dateTime
    DECLARE @logOut dateTime

    SET @logIn = GetDate()

    SELECT @IsUpdate = count(id) FROM test WHERE upper(id) = upper(@id)

    IF @IsUpdate > 0

        IF @logIn IS NOT NULL AND @logOut IS NULL
                UPDATE test
                SET @logOut = GetDate(), @totalHour = DATEDIFF(hour,@logIn,@logOut), @totalMinute = DATEDIFF(minute,@logIn,@logOut), @totalSecond = DATEDIFF(second,@logIn,@logOut)
                INSERT INTO test(id,logIn)
                VALUES (@id,@logIn);
        INSERT INTO test(id,logIn)
        VALUES (@id,@logIn);

Reply With Quote
  #2 (permalink)  
Old January 22nd, 2008, 12:32 AM
Friend of Wrox
Join Date: Oct 2007
Location: , , .
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi

I think you have not initialised logouttime. before using it

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure muthu555 SQL Server 2000 1 March 5th, 2007 07:13 AM
Calling on a database within a stored procedure Hadware SQL Language 1 January 8th, 2007 05:11 PM
Stored Procedure bmains SQL Server ASP 2 October 8th, 2004 03:19 AM
Stored Procedure to.... flyin ADO.NET 3 March 3rd, 2004 02:01 AM
C# and stored procedure Msmsn C# 1 August 26th, 2003 11:03 PM

All times are GMT -4. The time now is 01:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.