November 27, 2011 at 6:33 pm
Hi,
I want to create views referring to invalid objects. The reason is that i don't have control on some, as of today, non-existing objects. How can i create such a view ?
Thanks.
November 27, 2011 at 6:35 pm
Adding a sample script and error (which i don't want to get)
create view dbo.test
as
select *
from dbo.non_existing_table
go
Msg 208, Level 16, State 1, Procedure test, Line 4
Invalid object name 'dbo.non_existing_table'.
November 27, 2011 at 9:05 pm
You can't do it while creating a view.
You could use the select inside a stored procedure and it would work at the creation time.
The call to the procedure will still generate an error if the objects don't exist though.
Best regards,
Best regards,
Andre Guerreiro Neto
Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2/MCSE/MCSA
November 28, 2011 at 12:04 am
Ok procedure is not really an option for me.
I am just looking for a way to create (or alter) view without server checking for existence of it's dependent objects.
Is there anyway other than directly creating a view through "create view" script where such dependency check won't happen ... E.g. i create view with valid objects and then update the syscomments with required changes... or something else anyone can think of ?
or may be i create view through dynamic code ...
November 28, 2011 at 12:08 am
pushpi2000 (11/28/2011)
Ok procedure is not really an option for me.I am just looking for a way to create (or alter) view without server checking for existence of it's dependent objects.
Is there anyway other than directly creating a view through "create view" script where such dependency check won't happen ... E.g. i create view with valid objects and then update the syscomments with required changes... or something else anyone can think of ?
or may be i create view through dynamic code ...
If it's possible:
1) Create the required tables
2) Create Views on them
3) Drop the tables.
November 28, 2011 at 8:28 am
pushpi2000 (11/27/2011)
Hi,I want to create views referring to invalid objects. The reason is that i don't have control on some, as of today, non-existing objects. How can i create such a view ?
Thanks.
Just curious, how do you expect to be able to create a view into a structure that doesn't exist? Not trying to sound snarky but that is like testing a system before it is developed. I understand the team dynamic but there are times that certain tasks just simply have to be done in a certain order and this one of them.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy