DDL script problem with view and function

C

cullump

Hi

I'm currently trying to generate a DDL script for SQL Server 2000 from
a Visio (for Enterprise Architects) database model which includes a
view calling a function.

E.g.

CREATE VIEW MyView
AS
SELECT
[Customer].[Name] AS CustomerName,
[dbo].MyFunction([Customer].[ID]) AS Result
FROM Customer

I've entered the code for MyFunction in the global code area. The
problem is that when the script is generated, the view definition is
written in the script before the function which means that script
throws an error

Server: Msg 208, Level 16, State 1, Procedure MyView, Line 14
Invalid object name 'dbo.MyFunction'.

when it is run. I could edit the script by hand so that the function is
created before the view, but I was hoping there might be an easier
solution. If anyone has an idea I would be most grateful.

Regards, Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top