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)
 Change date in a transaction

Author  Topic 

munnik
Starting Member

3 Posts

Posted - 2007-12-17 : 06:02:12
Hi,

I've using several stored procedures that have a getdate() in them. I can't change the stored procedures but I want to get the results as if the sp is called in the past.

Example: sp get_users return 5 rows today but yesterday it returned 3 rows.

Is there a way to call the stored procedure in the 'past'

thanks,
Martijn

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-17 : 06:47:05
Only if the SP allows parameters.
If the date parameters defaults to GETDATE(), you can pass any date in and override the default.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

munnik
Starting Member

3 Posts

Posted - 2007-12-17 : 09:08:29
quote:
Originally posted by Peso

Only if the SP allows parameters.
If the date parameters defaults to GETDATE(), you can pass any date in and override the default.



The SP doesn't allow parameters, I was talking about changing some environment parameters that are only used in that session.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-17 : 09:10:59
Please don't.
That operation will affect all users connected to the database server.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

munnik
Starting Member

3 Posts

Posted - 2007-12-17 : 09:14:39
So there is no whay to only do it for the current transaction?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-17 : 09:18:58
Hmmm... No.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-17 : 09:22:42
Why dont you create new procedure with datetime parameter?

Madhivanan

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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-17 : 09:26:02
quote:
Originally posted by munnik

I can't change the stored procedures



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-17 : 09:29:21
quote:
Originally posted by Peso

quote:
Originally posted by munnik

I can't change the stored procedures



E 12°55'05.25"
N 56°04'39.16"



Thats why I suggested OP to create new procedure

Madhivanan

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

- Advertisement -