Unanswered: SQL 2000 -> SQL 2005 Nesting Error
I have sort of a weird error when attempting to create a database in SQL 2005 (migrating from SQL 2000 to SQL 2005).
I am able to run the CREATE PROC script just fine in SQL 2000, but I get this error in SQL 2005.
I can't easily past up the whole script(it's 2655 lines), but it basically takes the following form:
Originally Posted by SQL 2005
CREATE FUNCTION dbo.Ugly (
@LastUpdate datetime ) RETURNS BIT
DECLARE @UpdatedStatus as bit
DECLARE @RecordCount as smallint
SET @RecordCount = 0
If @TabelID = 1 -- Comment about TableName
@RecordCount = count(UNIQUE_ID)
UNIQUE_ID = @PK1
AND PROXY_ID = @PK2
AND LTRIM(RTRIM(ISNULL(LAST_UPDATE_BY,''))) = LTRIM(RTRIM(ISNULL(@UpdatedBy,'')))
isnull(LAST_UPDATE_DATE,'') = isnull(@UpdatedDt,'')
+ ' ' + convert(char(8), LAST_UPDATE_DATE,8)) = @UpdatedDt
If @TableID = 2 -- Comment about TableName
If @TableID = 3 -- Comment about TableName
If @TableID = 156 -- Comment about TableName
IF @RecordCount = 0
SET @UpdatedStatus = 1
SET @UpdatedStatus = 0
First, THIS IS NOT MY CODE.
Second, it appears that they are trying to create a function to test if a record has been updated (I cut out a bit of that).
I don't really get why SQL 2005 throws an error here. Yes, the code is hideous and not something that I would write myself. But it's not like the function is calling itself recursively or anything.
Can anyone shed any light?
Have you hugged your backup today?