How can we help you today? How can we help you today?
informatika
No, SP1 doesn't help. Now I put my problem into SQL Compare 5. I also have an example for you, to try out. Thanks, ;-), Mike / comments
No, SP1 doesn't help. Now I put my problem into SQL Compare 5. I also have an example for you, to try out. Thanks, ;-), Mike
0 votes
Hello Brian, thanks for reply. I use 'include dependencies' that's not the problem. Following your answer, I tried to disable transactions, but the problem remains. I looked into the skript. It's not because of transactions. The functions are really in the wrong order ... Here are the parts of the skript: The function KsBaum needs the Function KsBerechtigung. But KsBerechtigung is created at the end of the skript. ..... GO @TRANCOUNT&gt;0 ROLLBACK TRANSACTION GO @TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END GO PRINT N'Creating [dbo].[KsBaum]' GO CREATE FUNCTION [dbo].[KsBaum] ( @Start_Kostenstelle_ID INT, @Anwender_ID INT = NULL, @Berechtigung INT = 0 ) RETURNS TABLE AS RETURN ( WITH KostenstelleBaum( Kostenstelle_ID ) AS ( SELECT Kostenstelle_ID FROM Kostenstelle WHERE Kostenstelle_ID = @Start_Kostenstelle_ID OR ( Gehoert_Zu_Kostenstelle_ID IS NULL AND @Start_Kostenstelle_ID IS NULL ) OR Gehoert_Zu_Kostenstelle_ID = Kostenstelle_ID UNION ALL SELECT Kostenstelle.Kostenstelle_ID FROM Kostenstelle INNER JOIN KostenstelleBaum ON KostenstelleBaum.Kostenstelle_ID = Kostenstelle.Gehoert_Zu_Kostenstelle_ID WHERE Kostenstelle.Kostenstelle_ID <> Kostenstelle.Gehoert_Zu_Kostenstelle_ID ) SELECT Kostenstelle.* FROM Kostenstelle INNER JOIN KostenstelleBaum ON KostenstelleBaum.Kostenstelle_ID = Kostenstelle.Kostenstelle_ID INNER JOIN dbo.KsBerechtigung( @Anwender_ID, @Berechtigung ) KostenstelleBerechtigung ON KostenstelleBerechtigung.Kostenstelle_ID = Kostenstelle.Kostenstelle_ID ) GO @TRANCOUNT&gt;0 ROLLBACK TRANSACTION GO @TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END GO PRINT N'Creating [dbo].[KsSort]' GO ..... @TRANCOUNT&gt;0 ROLLBACK TRANSACTION GO @TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END GO PRINT N'Creating [dbo].[KsBerechtigung]' GO CREATE FUNCTION [dbo].[KsBerechtigung] ( @Anwender_ID INT, @Berechtigung INT ) RETURNS TABLE AS RETURN ( WITH KostenstelleBerechtigung( Kostenstelle_ID ) AS ( SELECT Kostenstelle.Kostenstelle_ID FROM Kostenstelle LEFT JOIN ZU_Anwender_Kostenstelle ON Kostenstelle.Kostenstelle_ID = ZU_Anwender_Kostenstelle.Kostenstelle_ID WHERE ZU_Anwender_Kostenstelle.Anwender_ID = @Anwender_ID OR @Berechtigung <= 20 UNION ALL SELECT Kostenstelle.Kostenstelle_ID FROM Kostenstelle INNER JOIN KostenstelleBerechtigung ON Kostenstelle.Gehoert_Zu_Kostenstelle_ID = KostenstelleBerechtigung.Kostenstelle_ID WHERE @Berechtigung > 20 ) SELECT DISTINCT Kostenstelle_ID FROM KostenstelleBerechtigung ) GO @TRANCOUNT&gt;0 ROLLBACK TRANSACTION GO @TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END GO By the way, in SQL Compare 5.0 I have the same problem. The only hint I have are the CTEs. Everything else is working fine. I had never problems. Any idea? Thank you for helping, ;-), Mike / comments
Hello Brian, thanks for reply. I use 'include dependencies' that's not the problem. Following your answer, I tried to disable transactions, but the problem remains. I looked into the skript. It's n...
0 votes