I wanted to see if the store procedures, functions, etc were consistant in the Impresario database. I ran this proc and it told me a lot of syntax errors in the various objects. I have not gone in too far of what the errors are. I thoght I mention it to see if anyone else found any as well. This is the code I used to detect the errors:
------------------------------------------------------------------------ Check Syntax of Database objects--------------------------------------------------------------------------- Turn on ParseOnly so that we don't actually execute anything.set parseonly on go
-- Create a table to iterate throughdeclare @objectList table (id_num int not null identity (1, 1), obj_name varchar(255), obj_type char(2))
-- Get a list of most of the scriptable objects in the DB.insert into @objectList (obj_name, obj_type)select name, typefrom sysobjects where type in ('P', 'FN', 'IF', 'TF', 'TR', 'V')order by type, name
-- Var to hold the SQL that we will be syntax checkingdeclare @SQLToCheckSyntaxFor varchar(max)-- Var to hold the name of the object we are currently checkingdeclare @objectName varchar(255)-- Var to hold the type of the object we are currently checkingdeclare @objectType char(2)-- Var to indicate our current location in iterating through the list of objectsdeclare @id_num int-- Var to indicate the max number of objects we need to iterate throughdeclare @maxid_num int-- set the inital value and max valueselect @id_num = Min(id_num), @maxid_num = Max(id_num)from @objectList
-- Begin iterationwhile @id_num <= @maxid_numbegin -- Load per iteration values here select @objectName = obj_name, @objectType = obj_type from @objectList where id_num = @id_num -- Get the text of the db object (ie create script for the sproc) select @SQLToCheckSyntaxFor = object_definition(object_id(@objectName, @objectType)) begin try -- Run the create script (remember that PARSEONLY has been turned on) exec (@SQLToCheckSyntaxFor) end try begin catch -- See if the object name is the same in the script and the catalog (kind of a special error) if (error_procedure() <> @objectName) begin print 'Error in ' + @objectName print ' The Name in the script is ' + error_procedure()+ '. (They don''t match)' end -- If the error is just that this already exists then we don't want to report that. else if (error_message() <> 'There is already an object named ''' + error_procedure() + ''' in the database.') begin -- Report the error that we got. print 'Error in ' + error_procedure() print ' Error Text: ' + error_message() end end catch
-- setup to iterate to the next item in the table select @id_num = case when Min(id_num) is null then @id_num + 1 else Min(id_num) end from @objectList where id_num > @id_num end-- Turn the ParseOnly back off.set parseonly offgo