473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to recompile / refresh UDFs ?

Ben
Hi!
I need to refresh an entire database.

I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).

Any help appreciated :) !

Ben

Mar 6 '07 #1
5 14451
Hi Ben,
Hi!
I need to refresh an entire database.

I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).

I'm afraid that no such procedure/DBCC command exists to recompile a
function. IMHO the best way to refresh function meta-data is to ALTER
it. That's better solution than dropping and creating (recreating) a
function, because when using ALTER FUNCTION permissions are retained.
--
Best regards,
Marcin Guzowski
http://guzowski.info
Mar 6 '07 #2
Ben (be****@gmail.com) writes:
I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).
What do you really want to achieve? sp_recompile and FLUSHPROCINDB just
removes plans out the query cache. sp_refreshview on the other hand
reinterprets the definition of the view, and this is necessary if
the view definition has an * in the select list. Thus the two serve
completely different purposes.

IF the problem is that you cannot refresh your inline table functions,
the simple solution is not to use SELECT *, which is generally considered
bad practice.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 6 '07 #3
Ben
What I'm trying to achieve, as I said:
I need to refresh an entire database.
So, all SPs, functions, and views.

The refresh problems arose when I changed a few columns' order : I
still receive all the data from the functions but they're incorrectly
ordered and labelled.
It gets even worse as some functions are nested (say, I select all
valid clients according to dates criteria, then all valid orders from
those clients, etc), or other functions are used in CHECK constraints
and so I SQL Server refuses to alter them, so I have to kil the
constraint, alter the function, and re-create the constraint... nice.

I heard about the "select * is bad practice", but I'm dealing with a
constantly evolving database (not yet in production), so I use a lot
of it to just pump everything and send it back to webpages. And even
if I didn't all that would mean is I'd have to manually go into every
function and update them, which is exactly what I've been doing so far
(open, backspace to alter, save --seems to be the only way to
refresh).

None of this is unsolvable, it just takes unnecessary time (one change
can mean 20 functions to track), and I can't find a way to do it
automatically.
Plus I find it really frustrating to be faced with compile problems
using a language that is supposed to be interpreted!
I get enough trouble updating DLLs, plus at least VS provides the
"recompile all" function...

Maybe if I do enough nagging my boss'll get me a SQL Server 2005.
Would that solve at least some of this?

Cheers, Ben.
On Mar 6, 11:50 pm, Erland Sommarskog <esq...@sommarskog.sewrote:
Ben (ben...@gmail.com) writes:
I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).

What do you really want to achieve? sp_recompile and FLUSHPROCINDB just
removes plans out the query cache. sp_refreshview on the other hand
reinterprets the definition of the view, and this is necessary if
the view definition has an * in the select list. Thus the two serve
completely different purposes.

IF the problem is that you cannot refresh your inline table functions,
the simple solution is not to use SELECT *, which is generally considered
bad practice.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Mar 19 '07 #4
Ben
Thanks, I knew about the ALTER solution, the only problem is I can
only do it manually (in the manager, open each function, backspace to
alter and enable the save button, and save).
Do you know any way to do the same automatically? (refresh ALL
functions, or the ENTIRE database) (PS: I can't rebuild it, have to
keep the data)

Cheers, Ben
On Mar 6, 6:17 pm, "Marcin A. Guzowski"
<tu_wstaw_moje_i...@guzowski.infowrote:
Hi Ben,
Hi!
I need to refresh an entire database.
I can recompile SPs with sp_recompile (or DBCC FLUSHPROCINDB), and
refresh views with sp_refreshView, but I cannot find any way to
refresh my user-defined functions (some of them are like views, with
parameters).

I'm afraid that no such procedure/DBCC command exists to recompile a
function. IMHO the best way to refresh function meta-data is to ALTER
it. That's better solution than dropping and creating (recreating) a
function, because when using ALTER FUNCTION permissions are retained.

--
Best regards,
Marcin Guzowskihttp://guzowski.info

Mar 19 '07 #5
Ben (be****@gmail.com) writes:
I heard about the "select * is bad practice", but I'm dealing with a
constantly evolving database (not yet in production), so I use a lot
of it to just pump everything and send it back to webpages. And even
if I didn't all that would mean is I'd have to manually go into every
function and update them, which is exactly what I've been doing so far
(open, backspace to alter, save --seems to be the only way to
refresh).
Not really. If you have everything under version control, or at least
on disk, you can easily run a BAT file that loads all functions it can
find. The database is no place for source code; in my opinion that is
only a container for binaries.

And while it may seem easy to have SELECT *, it does come back and bite
you. As I understood, you got this problem because you changed the column
order. If you had used explicit column lists, you could just have
changed the column lists, and you would have to change the underlying
tables.

I work with a constantly evolving database, for over ten years now. One
thing I hate is to find a stored procedure to return about every column
in a table. Then I have to dig further into the client code so see if
the column I want to drop or redefine is actually use somewhere. So there
are very good reasons to only return the columns that actually are
in use. This makes it much easier to track down where things are used.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew Mayo | last post by:
There is something very strange going on here. Tested with ADO 2.7 and MSDE/2000. At first, things look quite sensible. You have a simple SQL query, let's say select * from mytab where col1 =...
16
by: DraguVaso | last post by:
Hi, I have a Windows Service running (made in VB.NET), and wanted to be able to change from time to time some parameters by changing them in the App.config. But it seems that the application...
4
by: Pete H | last post by:
Hi All; I'm trying to get some of the samples that are amply illustrated in multiple docs to work. When I try to create a Warehouse Center view "...for MQ Series messages" or use the UDF wizard in...
7
by: Rhino | last post by:
I am updating some Java UDFs from DB2GENERAL to DB2JAVA as suggested in the manuals for DB2 Version 8 but I'm having problems with setSQLstate() and setSQLmessage(). If I'm reading the manuals...
2
by: MB | last post by:
Hello! At home I am using ASP.net to develop an asp application. Now I have copied this application to my IIS5.0 server at my workplace. Everything works fine, but then I would do a change in a...
3
by: jefftyzzer | last post by:
Friends, Say I have the following UDF: CREATE FUNCTION GET_MONTH(P_DATE DATE) RETURNS INTEGER INHERIT SPECIAL REGISTERS SPECIFIC GET_MONTH DETERMINISTIC BEGIN ATOMIC
0
by: Helmut Tessarek | last post by:
Hi everybody, I've written some UDFs to generate passwords within DB2. They are compatible to the functions that are used in Apache's htpasswd utility. Maybe someone can use them. ...
6
by: Carsten | last post by:
Hello Folks, I encountered a problem with SQL server 2000 and UDFs. I have a scalar UDF and a table UDF where I would like the scalar UDF to provide the argument for the table UDF like in: ...
0
by: sqldba20 | last post by:
Is there a way (command or stored procedure) to RECOMPILE or REFRESH a USER DEFINED FUNCTION? I can recompile SPs with sp_recompile and refresh views with sp_refreshView, but I could not find any way...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.