I am doing some T-SQL programming and I have some Views defines on my database. The data model is still changing these days and I have some table functions defined. Sometimes i deliberately use
select * from MYVIEW
in such a table function to return all columns. If the view changes (or table) the function crashes and I need to recompile it. I know it is in general good thing so that it prevents from hell lotta errors but still…
Is there a way to write such functions so the dont’ blow up in my face everytime I change something on the underlying table? Or maybe I am doing something completely wrong…
Thanks for help
Define views as “WITH SCHEMABINDING”
And I’ll refer you to my answer here which covers similar stuff…
“select * from table” vs “select colA,colB,etc from table” interesting behaviour in SqlServer2005
In this case, the problem is not the udf but how views behave without SCHEMABINDING
Edit: Cade Roux’s sp_refreshsqlmodule might do the trick. I’ve never used it.