2012年2月14日星期二

Disable dependence checks when creating view

Is it possible to disable checks for existance of referenced tables(views,
user functions) when creating new view
Thanks in advance.Only way would be through CREATE SCHEMA:
CREATE SCHEMA AUTHORIZATION ross
create view v as select * from t
create table t(c1 int)
More information in Books Online.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Amid" <Amid@.discussions.microsoft.com> wrote in message
news:DEFF0F05-66DD-4ABF-A483-9D934E8A529C@.microsoft.com...
> Is it possible to disable checks for existance of referenced tables(views,
> user functions) when creating new view
> Thanks in advance.|||Thanks for the quick reply.
What if i'm unable to create table [t] within the same statement where [v]
is created?
I need to create it much later.
Any help will be appreciated.
"Tibor Karaszi" wrote:

> Only way would be through CREATE SCHEMA:
> CREATE SCHEMA AUTHORIZATION ross
> create view v as select * from t
> create table t(c1 int)
> More information in Books Online.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Amid" <Amid@.discussions.microsoft.com> wrote in message
> news:DEFF0F05-66DD-4ABF-A483-9D934E8A529C@.microsoft.com...
>|||You can't do that. When a view is created, SQL Server need to populate the s
ystem tables
(syscolumns) with the columns that the view has (the SELECT in the view defi
nition). SQL Server
cannot do that if the table(s) that the view uses doesn't exist.
Why do you have this need? Sounds like a strange requirement to me...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Amid" <Amid@.discussions.microsoft.com> wrote in message
news:2C520E2E-FE0C-41D7-95C8-DA19CB87A78F@.microsoft.com...
> Thanks for the quick reply.
> What if i'm unable to create table [t] within the same statement where [v]
> is created?
> I need to create it much later.
> Any help will be appreciated.
> "Tibor Karaszi" wrote:
>|||I need to make copy of the database structure (tables, views, sp, uddt, uf,
constraints etc) with several modifications. Unfortunately original database
may me inconsistent (views, user functions in it may refer to the others
database tables or views). Now I cant gain access to that tables but
structure has to be copied. Thus I need to create views and user function
(sp) without actually having needed tables or views.
Thanks.
"Tibor Karaszi" wrote:

> You can't do that. When a view is created, SQL Server need to populate the
system tables
> (syscolumns) with the columns that the view has (the SELECT in the view de
finition). SQL Server
> cannot do that if the table(s) that the view uses doesn't exist.
> Why do you have this need? Sounds like a strange requirement to me...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Amid" <Amid@.discussions.microsoft.com> wrote in message
> news:2C520E2E-FE0C-41D7-95C8-DA19CB87A78F@.microsoft.com...
>

没有评论:

发表评论