Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server UDF refresh

I have altered the column datatype in one of my tables from int to decimal.

I have a UDF referencing the columns of this table.

How can I ensure my UDF returns decimals rather than int without having to re-create it?

(For view, I know we can use sp_refreshview, not sure about UDF).

Thanks, Rashmi

like image 576
SO User Avatar asked Oct 07 '11 06:10

SO User


People also ask

Can you modify data inside a UDF?

You cannot modify data inside of a UDF. A scalar-valued UDF returns only one value, where a stored procedure can have numerous OUTPUT parameters. You can use scalar-valued UDFs as the default value for a column in a table.

How do I refresh a stored procedure in SQL Server?

Open any stored procedure (right-click and choose Modify) From the Menu, choose Edit > Intellisense > Refresh Local Cache.

How do you update a function in SQL Server?

Use SQL Server Management Studio Select on the plus sign next to the database that contains the function you wish to modify. Select on the plus sign next to the Programmability folder. Select the plus sign next to the folder that contains the function you wish to modify: Table-valued Function.


1 Answers

I assume you are talking about an inline TVF in which case you can use

EXEC sp_refreshsqlmodule 'YourTVF'
like image 175
Martin Smith Avatar answered Sep 30 '22 03:09

Martin Smith