ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Return Table from Function in SQL Server<p>Hi&nbsp;chetan,</p> <p>I have made use of the following table Customers with the schema as follows.</p> <p><img src="https://www.aspsnippets.com/Handlers/DownloadFile.ashx?File=f18ac914-bc9b-437a-88e2-bd640ce05282.png" alt="" width="384" height="137" /></p> <p>I have already inserted few records in the table.</p> <p><img src="https://www.aspsnippets.com/Handlers/DownloadFile.ashx?File=b736972b-595c-4656-ab75-976e054877c7.png" alt="" width="340" height="156" /></p> <p>You can download the database table SQL by clicking the download link below.</p> <p><a href="https://www.aspsnippets.com/DownloadFile.aspx?File=Customers_Table_AutoIncrement.sql">Download SQL file</a></p> <p><strong><span style="text-decoration: underline;">SQL</span></strong></p> <pre class="brush: sql">CREATE FUNCTION fn_GetCustomers() RETURNS @tblCustomers TABLE ( Id INT NULL, Name VARCHAR(100) NULL, Country VARCHAR(50) NULL ) AS BEGIN INSERT INTO @tblCustomers SELECT * FROM Customers RETURN END GO SELECT * FROM fn_GetCustomers()</pre> <p><strong><span style="text-decoration: underline;">Output</span></strong></p> <table border="1"> <tbody> <tr> <td><strong>Id</strong></td> <td><strong>Name</strong></td> <td><strong>Country</strong></td> </tr> <tr> <td>1</td> <td>John Hammond</td> <td>United States</td> </tr> <tr> <td>2</td> <td>Mudassar Khan</td> <td>India</td> </tr> <tr> <td>3</td> <td>Suzanne Mathews</td> <td>France</td> </tr> <tr> <td>4</td> <td>Robert Schidner</td> <td>Russia</td> </tr> </tbody> </table>https://www.aspforums.net:443/Threads/840896/Return-Table-from-Function-in-SQL-Server/https://www.aspforums.net:443/Threads/840896/Return-Table-from-Function-in-SQL-Server/Fri, 01 Mar 2019 01:05:07 GMT