Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL Server: How do I ignore errors on a view creat

Author  Topic 

Joseph Schrag
Starting Member

13 Posts

Posted - 2010-06-02 : 19:47:07
I have a sql script which creates a view. This view references a table that does not exist when the view is created. So, it throws an error. I am wondering how I can catch the error and allow the view to be created anyway with no error thrown (important). I have tried wrapping it in a try catch, but it seems that is not allowed. I have tried using an if (@@error <> 0) statement, but it doesn't stop the error from being thrown.

I just want to prevent the error from being returned at all. I have also found that Oracle has exactly what I want (CREATE FORCE VIEW), but that is not available in SQL Server.

Any ideas?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-02 : 19:55:10
I don't think this is possible in SQL Server. Could you at least create a dummy table until the real table is ready?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Joseph Schrag
Starting Member

13 Posts

Posted - 2010-06-03 : 00:19:18
I think that is the route I will have to end up going.
Go to Top of Page
   

- Advertisement -