Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Sql Dependent Queries Not Automatically Recompiled

$
0
0

Hi there,

I am a simple guy, wondering what is going wrong:

I make 2 TVF's the second depending on the first. If I alter the first, the second one still used the old version of the first TVF. It seems the second TVF is not recompiled automatically, therefore displaying a wrong resultset!!!!

Why are dependent objects not automatically recompiled after the object it depends on has been altered?

Regards Jos

Use							Baanstede_Test
GO
Alter						Function				SynchTest1
(
)
Returns						Table
As
Return
Select						1						As	One
	,						2						As	Two
--	,						2.5						As	TwoAndHalf
	,						3						As	Three
--	,						3.5						As	ThreeAndHalf
	,						4						As	Four
Go
Select						*
From						SynchTest1()

One         Two         Three       Four
----------- ----------- ----------- -----------
1           2           3           4

(1 row(s) affected)

Use							Baanstede_Test
GO
Alter						Function				SynchTest2
(
)
Returns						Table
As
Return
Select						*
	,						5					As	Five
	,						6					As	Six
From						SynchTest1()
Go
Select						*
From						SynchTest2()

One         Two         Three       Four        Five        Six
----------- ----------- ----------- ----------- ----------- -----------
1           2           3           4           5           6

(1 row(s) affected)

Use							Baanstede_Test
Select						*
From						SynchTest1()
Select						*
From						SynchTest2()

One         Two         Three       Four
----------- ----------- ----------- -----------
1           2           3           4

(1 row(s) affected)

One         Two         Three       Four        Five        Six
----------- ----------- ----------- ----------- ----------- -----------
1           2           3           4           5           6

(1 row(s) affected)


Use							Baanstede_Test
GO
Alter						Function				SynchTest1
(
)
Returns						Table
As
Return
Select						1						As	One
	,						2						As	Two
	,						2.5						As	TwoAndHalf
	,						3						As	Three
	,						3.5						As	ThreeAndHalf
	,						4						As	Four
Go
Select						*
From						SynchTest1()

One         Two         TwoAndHalf                              Three       ThreeAndHalf                            Four
----------- ----------- --------------------------------------- ----------- --------------------------------------- -----------
1           2           2.5                                     3           3.5                                     4

(1 row(s) affected)


Use							Baanstede_Test
Select						*
From						SynchTest1()
Select						*
From						SynchTest2()

One         Two         TwoAndHalf                              Three       ThreeAndHalf                            Four
----------- ----------- --------------------------------------- ----------- --------------------------------------- -----------
1           2           2.5                                     3           3.5                                     4

(1 row(s) affected)

One         Two         Three                                   Four        Five                                    Six
----------- ----------- --------------------------------------- ----------- --------------------------------------- -----------
1           2           2.5                                     3           3.5                                     4

(1 row(s) affected)





I'll be back


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>