{"id":26468,"date":"2023-06-05T07:13:00","date_gmt":"2023-06-05T05:13:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=26468"},"modified":"2023-08-07T22:32:26","modified_gmt":"2023-08-07T20:32:26","slug":"sql-server-table-valued-functions","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/","title":{"rendered":"How to use SQL Server Table-Valued Functions?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\" id=\"h-sql-server-table-valued-functions-with-t-sql-practical-examples\"><strong><em>SQL Server table valued functions with T-SQL practical examples.<\/em><\/strong><\/h4>\n\n\n\n<p>Table-valued functions in SQL Server are a type of user-defined function that return a table data type. These functions are a powerful tool that can help organize your SQL code, facilitate code reuse, and provide a layer of abstraction over your data operations.<\/p>\n\n\n\n<p>Much like a <a href=\"https:\/\/expert-only.com\/en\/t-sql\/manage-sql-server-user-defined-functions\/\">traditional SQL function<\/a>, table-valued functions allow you to encapsulate complex logic within a function, providing an easier way to manage and maintain complex SQL queries. However, unlike scalar functions that return a single value, table-valued functions return a result set in the form of a table. T-SQL function are similar to <a href=\"https:\/\/functions.wolfram.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">mathematical functions<\/a>.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#1-introduction-to-sql-server-table-valued-functions\" >1. Introduction to SQL Server Table-Valued Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#2-creating-a-basic-function-to-return-a-table\" >2. Creating a basic Function to return a table<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#3-modifying-a-table-valued-function\" >3. Modifying a Table-Valued Function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#4-sql-server-table-valued-functions-with-parameters\" >4. SQL Server Table-Valued Functions with parameters<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#5-joining-results-from-table-valued-functions\" >5. Joining Results from Table-Valued Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#6-using-aggregations-with-table-valued-functions\" >6. Using Aggregations with Table-Valued Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#7-nested-table-valued-functions\" >7. Nested Table-Valued Functions<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-1-introduction-to-sql-server-table-valued-functions\"><span class=\"ez-toc-section\" id=\"1-introduction-to-sql-server-table-valued-functions\"><\/span>1. Introduction to SQL Server Table-Valued Functions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To understand the concept of table-valued functions in SQL Server, it becomes necessary to create a sample table. Let&#8217;s create the &#8216;Products&#8217; table with the following SQL statement and insert some records:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE TABLE Products(\n    ProductID int PRIMARY KEY,\n    Name varchar(100),\n    Description varchar(500),\n    Price decimal(10,2),\n    Category varchar(100)\n);\n\nINSERT INTO Products(ProductID, Name, Description, Price, Category) \nVALUES (1, 'Refrigerator', 'Large with double doors', 1500.00, 'Electronics'),\n       (2, 'Microwave', 'Compact with quick heating feature', 200.00, 'Electronics'),\n       (3, 'Television', '55 inches with 4K resolution', 1200.00, 'Electronics');\n<\/pre>\n\n\n\n<p>Table-valued functions in SQL Server return a table data type. This feature allows us to create reusable code that can appear to behave much like a table or a view.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-2-creating-a-basic-function-to-return-a-table\"><span class=\"ez-toc-section\" id=\"2-creating-a-basic-function-to-return-a-table\"><\/span>2. Creating a basic Function to return a table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let&#8217;s start by creating a simple table-valued function. This function will return all the products in the &#8216;Products&#8217; table. The important option is triggered by the keyword <strong><em>RETURNS TABLE<\/em><\/strong>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE FUNCTION getAllProducts()\nRETURNS TABLE \nAS\nRETURN \n(\n    SELECT * FROM Products\n);\n<\/pre>\n\n\n\n<p>To use this function, write a basic SELECT statement:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT *\nFROM getAllProducts();\n<\/pre>\n\n\n\n<p>The above function and query will return all the records from the &#8216;Products&#8217; table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3-modifying-a-table-valued-function\"><\/span>3. Modifying a Table-Valued Function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Just like other database objects, table-valued functions may require modifications over time to meet changing requirements or fix issues. You can&#8217;t directly modify a function in SQL Server, but you can drop and recreate it. However, keep in mind that dropping a function can impact other database objects that depend on it, such as stored procedures, views, or other functions.<\/p>\n\n\n\n<p>SQL Server provides the <code>ALTER FUNCTION<\/code> statement that lets you modify an existing function without dropping it. This statement allows you to redefine the function body, change the return type, or modify the parameters. Let&#8217;s say we want to modify it so it returns only the product names and prices, not the entire product records. We could do that with the <code>ALTER FUNCTION<\/code> statement:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ALTER FUNCTION getProductsByCategory(@category varchar(100))\nRETURNS TABLE \nAS\nRETURN \n(\n    SELECT Name, Price FROM Products WHERE Category = @category\n);\n<\/pre>\n\n\n\n<p>Make sure to thoroughly test your functions after modification, as changes may affect the function&#8217;s behavior and, subsequently, any dependent database objects or application code. It&#8217;s also good practice to maintain version control and backups of your SQL functions and procedures to allow easy rollback if necessary.<\/p>\n\n\n\n<p>Certainly, let&#8217;s take the previously defined <code>getProductsByCategory<\/code> function and modify it. The original function looked like this:<\/p>\n\n\n\n<p>Now, when you call the <code>getProductsByCategory<\/code> function, it will only return the product names and prices in the specified category. This demonstrates how you can use the <code>ALTER FUNCTION<\/code> statement to modify the behavior of a table-valued<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-4-sql-server-table-valued-functions-with-parameters\"><span class=\"ez-toc-section\" id=\"4-sql-server-table-valued-functions-with-parameters\"><\/span>4. SQL Server Table-Valued Functions with parameters<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Adding parameters to a table-valued function can allow you to filter the data returned. Let&#8217;s create a function that allows you to filter the products by category:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE FUNCTION getProductsByCategory(@category varchar(100))\nRETURNS TABLE \nAS\nRETURN \n(\n   SELECT *\n   FROM Products\n   WHERE Category = @category\n);\n<\/pre>\n\n\n\n<p>To use this function, pass the category as an argument in a SELECT statement:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT * FROM getProductsByCategory('Electronics');\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-5-joining-results-from-table-valued-functions\"><span class=\"ez-toc-section\" id=\"5-joining-results-from-table-valued-functions\"><\/span>5. Joining Results from Table-Valued Functions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We can treat the result from a table-valued function like any other table. For instance, you can join it with other tables or even other functions. Let&#8217;s create a &#8216;Categories&#8217; table and a function to demonstrate this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE TABLE Categories(\n    CategoryID int PRIMARY KEY,\n    CategoryName varchar(100)\n);\n\nINSERT INTO Categories(CategoryID, CategoryName) \nVALUES (1, 'Electronics'),\n       (2, 'Appliances'),\n       (3, 'Furniture');\n\nCREATE FUNCTION getCategoryByID(@CategoryID int)\nRETURNS TABLE \nAS\nRETURN \n(\n    SELECT * FROM Categories WHERE CategoryID = @CategoryID\n);\n<\/pre>\n\n\n\n<p>Now, let&#8217;s join the result from <code>getProductsByCategory<\/code> function with the result from <code>getCategoryByID<\/code> function:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT P.*, C.CategoryName \nFROM getProductsByCategory('Electronics') AS P\nJOIN getCategoryByID(1) AS C\nON P.Category = C.CategoryID;\n<\/pre>\n\n\n\n<p>This will return all the electronic products along with their category name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-6-using-aggregations-with-table-valued-functions\"><span class=\"ez-toc-section\" id=\"6-using-aggregations-with-table-valued-functions\"><\/span>6. Using Aggregations with Table-Valued Functions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Just like a regular table, you can perform aggregation operations on the results returned from a table-valued function. Let&#8217;s create a function to calculate the average price of products in a certain category:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE FUNCTION averagePriceByCategory(@category varchar(100))\nRETURNS TABLE \nAS\nRETURN \n(\n    SELECT AVG(Price) as AveragePrice FROM Products WHERE Category = @category\n);\n<\/pre>\n\n\n\n<p>You can call this function like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT *\nFROM averagePriceByCategory('Electronics');\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-7-nested-table-valued-functions\"><span class=\"ez-toc-section\" id=\"7-nested-table-valued-functions\"><\/span>7. Nested Table-Valued Functions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can nest table-valued functions inside other table-valued functions. To demonstrate this, let&#8217;s create a function that returns the products with a price higher than the average price in their category:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE FUNCTION productsAboveAveragePrice()\nRETURNS TABLE \nAS\nRETURN \n(\n    SELECT P.* FROM Products P\n    WHERE P.Price > (SELECT AveragePrice FROM averagePriceByCategory(P.Category))\n);\n<\/pre>\n\n\n\n<p>The <code>productsAboveAveragePrice<\/code> function uses the <code>averagePriceByCategory<\/code> function to get the average price of products in each category and then returns the products with a price higher than this average.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h3>\n\n\n\n<p>Table-valued functions in SQL Server offer a versatile tool for creating reusable pieces of SQL code. They can return tables which you can use in joins, perform aggregation operations on, or even nest inside other table-valued functions. Understanding their use can help you write more efficient and maintainable SQL code.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>SQL Server table valued functions with T-SQL practical examples. Table-valued functions in SQL Server are a type of user-defined function that return a table data type. These functions are a powerful tool that can help organize your SQL code, <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/\" title=\"How to use SQL Server Table-Valued Functions?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":6520,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-26468","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use SQL Server Table-Valued Functions? T-SQL<\/title>\n<meta name=\"description\" content=\"Tutorial about SQL Server table-valued functions with T-SQL practical examples to create, call and objects with parameters and joins.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use SQL Server Table-Valued Functions?\" \/>\n<meta property=\"og:description\" content=\"Tutorial about SQL Server table-valued functions with T-SQL practical examples to create, call and objects with parameters and joins.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-05T05:13:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-07T20:32:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to use SQL Server Table-Valued Functions?\",\"datePublished\":\"2023-06-05T05:13:00+00:00\",\"dateModified\":\"2023-08-07T20:32:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/\"},\"wordCount\":746,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/\",\"name\":\"How to use SQL Server Table-Valued Functions? T-SQL\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg\",\"datePublished\":\"2023-06-05T05:13:00+00:00\",\"dateModified\":\"2023-08-07T20:32:26+00:00\",\"description\":\"Tutorial about SQL Server table-valued functions with T-SQL practical examples to create, call and objects with parameters and joins.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use SQL Server Table-Valued Functions?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to use SQL Server Table-Valued Functions? T-SQL","description":"Tutorial about SQL Server table-valued functions with T-SQL practical examples to create, call and objects with parameters and joins.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/","og_locale":"en_US","og_type":"article","og_title":"How to use SQL Server Table-Valued Functions?","og_description":"Tutorial about SQL Server table-valued functions with T-SQL practical examples to create, call and objects with parameters and joins.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-06-05T05:13:00+00:00","article_modified_time":"2023-08-07T20:32:26+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to use SQL Server Table-Valued Functions?","datePublished":"2023-06-05T05:13:00+00:00","dateModified":"2023-08-07T20:32:26+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/"},"wordCount":746,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/","url":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/","name":"How to use SQL Server Table-Valued Functions? T-SQL","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg","datePublished":"2023-06-05T05:13:00+00:00","dateModified":"2023-08-07T20:32:26+00:00","description":"Tutorial about SQL Server table-valued functions with T-SQL practical examples to create, call and objects with parameters and joins.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/code-1839406_1920.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-table-valued-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to use SQL Server Table-Valued Functions?"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/26468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=26468"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/26468\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/6520"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=26468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=26468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=26468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}