Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2000-10-12 : 00:28:17
|
This article covers all the basics of User Defined Functions. It discusses how (and why) to create them and when to use them. It talks about scalar, inline table-valued and multi-statement table-valued functions. Article Link. |
|
Robse
Starting Member
1 Post |
Posted - 2004-09-02 : 23:31:03
|
Nice Article! But I'm still having trouble with determining when to use a UDF...I'm thinking that in your first example, 'USA' could return 'Unknown' ? Seems logical ;) |
|
|
Texrat
Starting Member
1 Post |
Posted - 2005-11-30 : 13:28:11
|
I appreciate the info, but for me a HUGE piece is missing. The article says it discusses how to create UDFs, but I don't see the part where we're told how to get those nifty functions into SQL Server. As a new SS developer that's the part I need the most and can't find anywhere. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-11-30 : 14:04:47
|
>>I don't see the part where we're told how to get those nifty functions into SQL ServerDid you see all the CREATE FUNCTION statements? That's how you create a function in SQL Server. If that's not what you mean, can you be more specific about what you need? |
|
|
aksam.iftikhar
Starting Member
1 Post |
Posted - 2009-07-25 : 12:28:27
|
quote: Originally posted by jsmith8858 >>I don't see the part where we're told how to get those nifty functions into SQL Server>>Did you see all the CREATE FUNCTION statements? That's how you create a function in SQL Server. If that's not what you mean, can you be more specific about what you need?
>> Well, you should use SQL Query Analyzer in SQL Server 2000 to type the CREATE FUNCTION command in. Once you complete the command you can execute it by pressing F5 and you're done.Muhammad Aksam IftikharPakistan |
|
|
praveenbattula
Starting Member
4 Posts |
Posted - 2010-06-04 : 14:41:47
|
Here is a small example, which helps to understand it better.T-SQL Split the giving string by delimiter and return result in a table.[url]http://praveenbattula.blogspot.com/2010/06/best-split-udf-function-with-delimeter.html[/url]Rare Solutionshttp://praveenbattula.blogspot.com |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2010-06-04 : 14:57:13
|
Hmmmmm....you might want to search the forum before you point people to a page entitle "Best" Split UDF function....There are methods which do not require a loop or a temporary table. There is a whole thread devoted to the topic here.________________________________________________If it is not practically useful, then it is practically useless.________________________________________________ |
|
|
Jim Snyder
Starting Member
1 Post |
Posted - 2015-03-24 : 10:06:01
|
I would have liked to see something about efficiency, or where UDFs are most useful. A UDF is serial in nature in an environment that is batch-oriented. This means if you are using a UDF to supply a column in a million row table, the UDF gets called a million times.Due to this, the most useful way to use a UDF in a SELECT is to make it short. My favorite uses include such things as formatting dates, phones, addresses, strings etc. Long functions with complex queries are probably better to do inline.Documentation + tidy style = maintainability |
|
|
|