ASPForums.Net RSS Feed additions to the content that appears on ASPForums.Net(c) 2019 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="" alt="" width="384" height="137" /></p> <p>I have already inserted few records in the table.</p> <p><img src="" alt="" width="340" height="156" /></p> <p>You can download the database table SQL by clicking the download link below.</p> <p><a href="">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>, 01 Mar 2019 01:05:07 GMT