Microsoft KB Archive/300272

= FIX: Transfer of a View that Contains a UDF by Using DTS Export Data Fails with Error 208 =

Article ID: 300272

Article Last Modified on 11/5/2003

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q300272



BUG #: 352081 (SHILOH_BUGS)



SYMPTOMS
Attempts to transfer a view by using the Data Transformation Service (DTS) Import/Export wizard fails under the following conditions:
 * The view includes a user-defined function (UDF).
 * When copying objects and data between SQL Server databases.

The following text is an example of the error message that displays:

Failed to copy objects from Microsoft SQL Server to Microsoft SQL Server

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.TestFunc'.

NOTE: &quot;dbo.TestFunc&quot; is the name of the UDF.



CAUSE
The view is being created in the destination database before the UDF, which is the dependent object. All the dependent objects must be created first.



RESOLUTION
To resolve this problem, obtain the latest service pack for 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
Transfer all the objects that the view depends on first, and then when you transfer the view, do not include dependent objects.



STATUS
Microsoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.



Steps to Reproduce Behavior
  In the source database, run this code to create the table, view and UDF: CREATE FUNCTION TestFunc RETURNS INT AS BEGIN RETURN 15 END go

CREATE TABLE dbo.TestTable ( col1 int NULL ) go

CREATE VIEW dbo.TestView AS SELECT col1, dbo.TestFunc AS FuncResults FROM dbo.TestTable go  Now, use the DTS Export/Import wizard to copy these to another SQL Server database. Select the Copy objects and data between SQL Server databases option. Leave all the scripting options at their default settings. This fails with the following error message in the .log file for the target database:

Transfer Status: Creating Views on destination database

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.TestFunc'.



To workaround this problem, copy the dependent table, TestTable, and the &quot;TestFunc&quot; UDF across first. Then copy the view with the Include all dependent objects option cleared.

Additional query words: 208 package

Keywords: kbbug kbfix kbsqlserv2000sp1fix KB300272

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.