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 |
|
ryanlcs
Yak Posting Veteran
62 Posts |
Posted - 2006-01-03 : 22:15:58
|
| 1. How can I call a store procedure withing a view?2. how can I retrieve the current date or time inside the "User Defined Function" within SQL Server? I tried GETDATE(), but it is not a recognize function.Pls help. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-03 : 22:31:44
|
| 1. you can't2. also can't. However you can pass in the current datetime to your function-----------------[KH]2006 a new beginning |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-04 : 00:08:29
|
Yes, if you use Stored Procedure instead of View MadhivananFailing to plan is Planning to fail |
 |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2006-01-04 : 00:12:26
|
| You cannot use a system defined function or stored procedure inside a function.RegardsSachinDon't sit back because of failure. It will come back to check if you still available. -- Binu |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-01-04 : 11:15:56
|
You can't use GETDATE() in a function, but...This is a trick to work around not being able to use GETDATE() in a User Defined Function by putting GETDATE() in a view and using the view in the function.This code shows how it works:create view V_GETDATEasselect [GETDATE] = getdate()gocreate function USE_GETDATE ()returns datetimeasbegindeclare @dt datetimeselect @dt = [getdate] from V_GETDATEreturn @dtendgoselect [GETDATE IN FUNCTIION] = dbo.USE_GETDATE()godrop function USE_GETDATEgodrop view V_GETDATE CODO ERGO SUM |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-04 : 19:31:39
|
| Nice trick MVJ-----------------[KH]2006 a new beginning |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-01-05 : 11:07:47
|
| Yeah, very ingenious |
 |
|
|
|
|
|