| Author |
Topic |
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-16 : 21:36:49
|
| Is there any nice neat way of doing something like an "Include" which is available in other progamming languages, for stored procedures? I realise you can call one SP from another, or use dynamic SQL & construct a string & execute it, but for example I would like a way to include a portion of the sql in a where clause when it is used in several SPs. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-16 : 21:41:33
|
"for example I would like a way to include a portion of the sql in a where clause when it is used in several SPs."Not possible. But you can create a view with the where conditions in there and reference that view instead of the base table(s) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-16 : 21:43:21
|
| Good point! |
 |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-16 : 21:44:37
|
| But in this situation I don't think it will work as the where needs to cater for params |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-16 : 21:46:15
|
then how about table function ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-16 : 21:49:08
|
| mmmm yes. I generally try to avoid functions due to being frustrated with limitations of what you can do in them in the past. But in this case, if there's nothing like an 'include' that's probably the best way to go. Thanks! |
 |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-16 : 21:50:37
|
| Are there any performance down-sides? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-16 : 22:00:44
|
Do test out and see any diff in performance  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-16 : 22:10:48
|
| Testing - what's that? :) |
 |
|
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2008-07-17 : 08:02:57
|
| http://weblogs.sqlteam.com/jeffs/archive/2007/05/23/60215.aspx |
 |
|
|
|