sql server 用戶定義的函數(shù)[外文翻譯].rar
sql server 用戶定義的函數(shù)[外文翻譯],sql server 用戶定義的函數(shù)[外文翻譯]包含中文翻譯和英文原文,內(nèi)容詳細(xì)完整,建議下載參考!中文: 4039 字英文: 12787字符用戶定義的函數(shù) (udf) 是準(zhǔn)備好的代碼片段,它可以接受參數(shù),處理邏輯,然后返回某些數(shù)據(jù)。根據(jù) sql server books online,sql server 2000 ...
該文檔為壓縮文件,包含的文件列表如下:
內(nèi)容介紹
原文檔由會(huì)員 xiaowei 發(fā)布
SQL Server 用戶定義的函數(shù)[外文翻譯]
包含中文翻譯和英文原文,內(nèi)容詳細(xì)完整,建議下載參考!
中文: 4039 字
英文: 12787字符
用戶定義的函數(shù) (UDF) 是準(zhǔn)備好的代碼片段,它可以接受參數(shù),處理邏輯,然后返回某些數(shù)據(jù)。根據(jù) SQL Server Books Online,SQL Server 2000 中的 UDF 可以接受從 0 到 1024 的任意個(gè)數(shù)的參數(shù),不過我必須承認(rèn),我還未嘗試將 1024 個(gè)參數(shù)傳遞到 UDF 中。UDF 的另一個(gè)關(guān)鍵特征是返回一個(gè)值。取決于 UDF 的類型,調(diào)用例程可以使用這個(gè)值來繼續(xù)處理它的數(shù)據(jù)。因此,如果 UDF 返回單一值(標(biāo)量值),調(diào)用例程就可以在任何能夠使用標(biāo)準(zhǔn)變量或文字值的地方使用這個(gè)值。如果 UDF 返回一個(gè)行集,則調(diào)用例程可以循環(huán)訪問該行集,聯(lián)接到該行集,或簡(jiǎn)單地從該行集中選擇列。
雖然現(xiàn)在大多數(shù)編程語言已經(jīng)暫時(shí)支持函數(shù),但只有 SQL Server 2000 引入了 UDF。存儲(chǔ)過程和視圖在 SQL Server 中可用的時(shí)間遠(yuǎn)早于 UDF,但這些對(duì)象中的每一個(gè)在 SQL Server 開發(fā)中都有自己適當(dāng)?shù)奈恢?。存?chǔ)過程可以很好地用于處理復(fù)雜的 SQL 邏輯、保證和控制對(duì)數(shù)據(jù)的訪問,以及將行集返回到調(diào)用例程,無論此例程是基于 Visual Basic® 的程序,還是另一個(gè) Transact-SQL (T-SQL) 批處理文件。與視圖不同,存儲(chǔ)過程是已編譯的,這使得它們成為用來表示和處理頻繁運(yùn)行的 SQL 語句的理想候選者。視圖可以很好地用于控制對(duì)數(shù)據(jù)的訪問,但它們的控制方式與存儲(chǔ)過程不同。視圖僅限于生成該視圖的基礎(chǔ) SELECT 語句中的某些列和行。因而視圖常用于表示常用的 SELECT 語句,該語句可以聯(lián)接多個(gè)表、使用 WHERE 子句,以及公開特定的列。在聯(lián)接到其他表和視圖的 SQL 語句的 FROM 子句中經(jīng)常會(huì)發(fā)現(xiàn)視圖 ......
SQL server User-defined Functions
Auser-defined function (UDF) is a prepared code segment that can accept parameters, process some logic, and then return some data. According to SQL Server Books Online, UDFs in SQL Server™ 2000 can accept anywhere from 0 to 1024 parameters, although I must confess I have never tried to pass 1024 parameters into a UDF. Another key characteristic of UDFs is that they return a value. Depending on the type of UDF, the value can be used by the calling routine to continue processing its data. Thus, if a UDF returns a single value (a scalar value), the calling routine can use that value anywhere a standard variable or a literal value can be used. If a UDF returns a rowset, the calling routine can loop through the rowset, join to it, or simply select columns from it.
While most programming languages have supported functions for a while now, UDFs were only introduced with SQL Server 2000. Stored procedures and views have been available in SQL Server much longer than UDFs, but each of these objects has their niche in SQL Server development. Stored procedures are great for processing complex SQL logic, securing and controlling access to data, and returning a rowset to a calling routine whether that routine is a Visual Basic®-based program or another Transact-SQL (T-SQL) batch. Unlike views, stored procedures are compiled, making them ideal candidates to represent and process frequently run SQL statements. Views are great for controlling access to data, but they do it differently than stored procedures. Views are limited to only certain columns and rows from the ......
包含中文翻譯和英文原文,內(nèi)容詳細(xì)完整,建議下載參考!
中文: 4039 字
英文: 12787字符
用戶定義的函數(shù) (UDF) 是準(zhǔn)備好的代碼片段,它可以接受參數(shù),處理邏輯,然后返回某些數(shù)據(jù)。根據(jù) SQL Server Books Online,SQL Server 2000 中的 UDF 可以接受從 0 到 1024 的任意個(gè)數(shù)的參數(shù),不過我必須承認(rèn),我還未嘗試將 1024 個(gè)參數(shù)傳遞到 UDF 中。UDF 的另一個(gè)關(guān)鍵特征是返回一個(gè)值。取決于 UDF 的類型,調(diào)用例程可以使用這個(gè)值來繼續(xù)處理它的數(shù)據(jù)。因此,如果 UDF 返回單一值(標(biāo)量值),調(diào)用例程就可以在任何能夠使用標(biāo)準(zhǔn)變量或文字值的地方使用這個(gè)值。如果 UDF 返回一個(gè)行集,則調(diào)用例程可以循環(huán)訪問該行集,聯(lián)接到該行集,或簡(jiǎn)單地從該行集中選擇列。
雖然現(xiàn)在大多數(shù)編程語言已經(jīng)暫時(shí)支持函數(shù),但只有 SQL Server 2000 引入了 UDF。存儲(chǔ)過程和視圖在 SQL Server 中可用的時(shí)間遠(yuǎn)早于 UDF,但這些對(duì)象中的每一個(gè)在 SQL Server 開發(fā)中都有自己適當(dāng)?shù)奈恢?。存?chǔ)過程可以很好地用于處理復(fù)雜的 SQL 邏輯、保證和控制對(duì)數(shù)據(jù)的訪問,以及將行集返回到調(diào)用例程,無論此例程是基于 Visual Basic® 的程序,還是另一個(gè) Transact-SQL (T-SQL) 批處理文件。與視圖不同,存儲(chǔ)過程是已編譯的,這使得它們成為用來表示和處理頻繁運(yùn)行的 SQL 語句的理想候選者。視圖可以很好地用于控制對(duì)數(shù)據(jù)的訪問,但它們的控制方式與存儲(chǔ)過程不同。視圖僅限于生成該視圖的基礎(chǔ) SELECT 語句中的某些列和行。因而視圖常用于表示常用的 SELECT 語句,該語句可以聯(lián)接多個(gè)表、使用 WHERE 子句,以及公開特定的列。在聯(lián)接到其他表和視圖的 SQL 語句的 FROM 子句中經(jīng)常會(huì)發(fā)現(xiàn)視圖 ......
SQL server User-defined Functions
Auser-defined function (UDF) is a prepared code segment that can accept parameters, process some logic, and then return some data. According to SQL Server Books Online, UDFs in SQL Server™ 2000 can accept anywhere from 0 to 1024 parameters, although I must confess I have never tried to pass 1024 parameters into a UDF. Another key characteristic of UDFs is that they return a value. Depending on the type of UDF, the value can be used by the calling routine to continue processing its data. Thus, if a UDF returns a single value (a scalar value), the calling routine can use that value anywhere a standard variable or a literal value can be used. If a UDF returns a rowset, the calling routine can loop through the rowset, join to it, or simply select columns from it.
While most programming languages have supported functions for a while now, UDFs were only introduced with SQL Server 2000. Stored procedures and views have been available in SQL Server much longer than UDFs, but each of these objects has their niche in SQL Server development. Stored procedures are great for processing complex SQL logic, securing and controlling access to data, and returning a rowset to a calling routine whether that routine is a Visual Basic®-based program or another Transact-SQL (T-SQL) batch. Unlike views, stored procedures are compiled, making them ideal candidates to represent and process frequently run SQL statements. Views are great for controlling access to data, but they do it differently than stored procedures. Views are limited to only certain columns and rows from the ......