| Author |
Topic |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2005-05-25 : 12:11:57
|
| T-SQL doesn't allow calling GETDATE() within a function.I'm going to have to code it to accept @GetDate a parameter (no big deal), but finding and modifying all the points that call the function is a lot of work.Anyone have an out that'll give me access to the date from within a function?Sam |
|
|
ajthepoolman
Constraint Violating Yak Guru
384 Posts |
Posted - 2005-05-25 : 12:46:17
|
| The parameter method is the only way I have found to get around it.I have tried GETDATE()dbo.GETDATE()and other ways, but you simply cannot do it. Some of the smarter people on this forum can explain it better, but in a nutshell SQL does not support the use of SOME functions within UDFs.Aj |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2005-05-25 : 13:04:55
|
| Schweet !Thanks Jeff,Sam |
 |
|
|
ajthepoolman
Constraint Violating Yak Guru
384 Posts |
Posted - 2005-05-25 : 13:58:27
|
| Great article Jeff! I suppose that work around could be used for just about any problem you have with UDF limitations.Aj |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-05-26 : 01:25:26
|
| A bit tangential 'coz clearly Jeff's solution rocks, but I create a new function MyFunction_V2 when I need to add a parameter, and then I can modify the code piecemeal (assuming the old calls are still valid, up to a point).You can also DROP the "V1" Function to force errors from old code (obvious an additional parameter requirement is going to create an error in old code! but its applicable to other circumstances where the new version now requires no code to be calling the old version - perhaps you've changed the basis of a return value, or somesuch.Kristen |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-05-26 : 09:01:30
|
D'oh !! Sorry David! I will add a little note to the beginning of my post ... However -- I can't help resist something I had noticed a few months ago when cleaning up the spam from my blog:http://weblogs.sqlteam.com/jeffs/archive/2003/09/30/195.aspxhttp://www.sqlteam.com/item.asp?ItemID=15044 I guess it happens! I think we all spend a *little* too much time together here at sqlteam !- Jeff |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-05-26 : 19:07:48
|
oops, you got me. Hadn't even noticed that blog.I think you're right.I have a bit of a grand scheme to rebuild SQLTeam so that blog articles can be front page articles, unify the lot... But that spare time thing is a bitch DamianIta erat quando hic adveni. |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2005-05-26 : 19:18:37
|
| Where reasonable people here.. So here is a solution.I sue Jeff, Jeff sues Damian, Damian sues me and then get we together and kill the lawyers.And Damian, if you think you are stretched for time now..wait till junior comes along!DavidMA front-end is something that tries to violate a back-end. |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2005-05-26 : 19:27:37
|
| It's my thread. I should sue all you guys. I just don't know what for. |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2005-05-26 : 20:07:59
|
| LOL Sam! Does it matter?DavidMA front-end is something that tries to violate a back-end. |
 |
|
|
ajthepoolman
Constraint Violating Yak Guru
384 Posts |
Posted - 2005-05-26 : 20:27:02
|
| You can sue me for having the least number of posts of all the people who posted here.Aj |
 |
|
|
|