FIX: Generate SQL Script in Enterprise Manager Generates Scripts in Wrong Sequence if the Table has User-Defined Function as Computed Column (289551)
The information in this article applies to:
- Microsoft SQL Server 2000 (all editions)
This article was previously published under Q289551
BUG #: 351235 (SHILOH_BUGS)
SYMPTOMS
If you use the Generate SQL Script option from the SQL Server Enterprise Manager against a table that has a user-defined function as a computed column, you must select the Generate Scripts for all dependent Objects option under the Formatting tab to script out the user-defined function as well. However, the Transact-SQL statements in the script that drop and re-create the function and the table are in the wrong order. So, when you attempt to re-create the table by executing the scripts, the following error message occurs:
Server: Msg 208, Level 16, State 1, Line 2
Invalid object name 'objectname'
CAUSE
SQL Server does not generate the scripts in the correct order.
RESOLUTIONTo resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the
Microsoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack
WORKAROUND
Manually change the orders of the DROP and CREATE statements for the table and the user-defined function, because the table creation requires the existence of the user-defined function.
The correct sequence is:
- Drop the table.
- Drop the user-defined function.
- Create the user-defined function.
- Create the table.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft SQL Server 2000 Service Pack 1.
Modification Type: | Major | Last Reviewed: | 11/6/2003 |
---|
Keywords: | kbBug kbfix kbSQLServ2000sp1fix KB289551 |
---|
|