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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 GetDate() twice return the same value

Author  Topic 

jhnegrao
Yak Posting Veteran

81 Posts

Posted - 2009-02-16 : 13:33:55
Hi, Good Afternoon!

I'm trying to create a stored procedure to audit an specific process. My Stored Procedure sometime has to create a record on a specific audit table using values with date and time.
This stored procedure can execute three times the function GETDATE(), but the value is the same. For exemplo:

Log 1: Feb 16 2009 4:22:15:127PM
Log 2: Feb 16 2009 4:22:15:127PM
Log 3: Feb 16 2009 4:22:15:127PM

I would like to write different values. I want the miliseconds values as well.

Anybody knows how to can I have different values using three times the function GETDATE() on the same Stored Procedure.

Best Regards

Juliano

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-16 : 13:43:48
Three different inserts will give three different times.
Use DELAY WAITFOR '00:00:00.004' between just in case.

However, it seems you are buildind some business logic with the dates...



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-02-17 : 01:37:02
Can you post the procedure code?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-17 : 03:19:33
seems like inserts are happening in quick succesion that its within maximum precision possible
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-17 : 03:41:32
DELAY WAITFOR, as I suggested in my post?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -