Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get information about table valued function

Tags:

sql

tsql

Is any way to get return table schema from table valued functions ?

Now i have only one idea, execute

SELECT ROUTINE_SCHEMA,

   ROUTINE_NAME,

   ROUTINE_DEFINITION

FROM INFORMATION_SCHEMA.ROUTINES

and parse the function query, but it isn't gread idea. :/

like image 293
user1091406 Avatar asked Jan 16 '12 16:01

user1091406


People also ask

How do you call a table-valued function?

The simple definition of the table-valued function (TVF) can be made such like that; a user-defined function that returns a table data type and also it can accept parameters. TVFs can be used after the FROM clause in the SELECT statements so that we can use them just like a table in the queries.

How do I find the value of a table in a database?

Use sys. For example, if we want to search only for the user-defined table, we use 'U' value for the type column. I filter records for the useful columns. You can get all columns using the select * statement. Similarly, we use the value 'P' for the stored procedure.

What will be the return type of a table-valued function?

A table-valued function returns a single rowset (unlike stored procedures, which can return multiple result shapes). Because the return type of a table-valued function is Table , you can use a table-valued function anywhere in SQL that you can use a table.


1 Answers

You can get the information from INFORMATION_SCHEMA.ROUTINE_COLUMNS

e.g.

SELECT * 
FROM INFORMATION_SCHEMA.ROUTINE_COLUMNS 
WHERE TABLE_NAME = 'YourTableValuedFunctionName'
like image 61
AdaTheDev Avatar answered Sep 28 '22 00:09

AdaTheDev