Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Enterprise Tools / January 2008

Tip: Looking for answers? Try searching our database.

VS DB Pro - Views created before tables in generated SQL scripts

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 10 Jan 2008 17:58 GMT
I'm using VS 2005 Team Suite and working with a Database project.

I've added views to the project that are built over a table that contains a
column defined as XML. All SQL scripts that I've created execute successfully
within SQL Server 2005.

I have the database project configured to create a new database each time it
is deployed. I am able to build the project without any errors or warnings.
However, deploying the project always fails.

Looking at the SQL script that VS uses to generate the database, I find that
the CREATE VIEW statements are placed near the top well above the CREATE
TABLE statements.

Clearly, this creates dependency issues.

Things I've tried:
- Based on MSDN documentation, I added the schema name "dbo" to the FROM
table name in my view scripts. This did not seem to fix the problem.
-  I created a view based on a different table that did not contain any XML
columns just for comparison sake and it worked. The CREATE VIEW statements
were placed in the appropriate location within the generated SQL script.

So...does anyone have any ideas as to why VS insists on placing my CREATE
VIEW statements at the top of the generated SQL script as opposed to after
the CREATE TABLE statements as it should?

Thanks for any help you can provide.

Signature

Dave

WenYuan Wang [MSFT] - 11 Jan 2008 08:03 GMT
Hello Dave,

According to your description, you added a view which is build over a table
contained a XML typed Column in Database project. But, the script file
generated by VS put the CREATE VIEW statement above the CREATE TABLE
statements. Therefore, this results a dependency issue. If I misunderstood
anything here, please don't hesitate to correct me.

It sounds like the XML column caused the issue. According to your
description, the issue will be resolved if you create a view on a different
table which doesn't contain any xml column, correct? I'm sorry, but we
haven't heard that before. Do you have detailed step to reproduce this
issue? Is it possible for you paste it in this thread? I need to reproduce
it on my side. Thereby, we can perform further research.

Please feel free to let me know if you have any more concern. I'm glad to
assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Dave - 11 Jan 2008 17:24 GMT
Wen-

Thanks for getting back to me. You're summary of the problem is correct.

Here is the table with the XML column that I referenced in my original post:

CREATE TABLE [dbo].[InProgress]
(
    [InProgressID] [uniqueidentifier] NOT NULL,
    [DeviceID] [varchar](50) NULL,
    [ResponseXML] [xml] (CONTENT dbo.MasterResponse) NULL,
    [RestoreFlag] [bit] NOT NULL,
    [InsertDate] [datetime] NOT NULL,
    [InsertBy] [varchar](128) NOT NULL,
    [UpdateDate] [datetime] NULL,
    [UpdateBy] [varchar](128) NULL,
    [HarvestUnitNumber] [varchar](50) NULL,
    [Unit] [varchar](50) NULL CONSTRAINT [DF_InProgress_Unit]  DEFAULT
('Unknown'),
    [TotalAcres] [decimal](18, 2) NULL CONSTRAINT [DF_InProgress_TotalAcres]  
DEFAULT ((0.00)),
    [ContractorID] [int] NULL,
    [Contractor] [varchar](50) NULL,
    [Crew] [varchar](50) NULL,
    [Org] [int] NULL,
    [RowVersion] [timestamp] NOT NULL,
    CONSTRAINT [PK_InProgress] PRIMARY KEY CLUSTERED
    (
        [InProgressID] ASC
    )
    WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY];

And here is one of the views created over this table:

CREATE VIEW [dbo].[ActionView]
AS

WITH
XMLNAMESPACES('http://www.companyname.com/Schemas/CPI/MasterResponse.xsd' AS
PC)

SELECT     InProgressID,
ISNULL(resp.items.value('(PC:ActionID)[1]', 'varchar(50)'), '') AS ActionID,
ISNULL(resp.items.value('(PC:InspectionID)[1]', 'varchar(50)'), '') AS
InspectionID,
ISNULL(resp.items.value('(PC:InspectionNumber)[1]', 'smallint'), 0) AS
InspectionNumber,
ISNULL(resp.items.value('(PC:TypeOfConsideration)[1]', 'varchar(50)'), '')
AS TypeOfConsideration,
ISNULL(resp.items.value('(PC:Action)[1]', 'varchar(128)'), '') AS Action,
ISNULL(resp.items.value('(PC:Rating)[1]', 'smallint'), 0)  AS Rating,
ISNULL(resp.items.value('(PC:InsertDate)[1]', 'datetime'), '12:00:00AM') AS
InsertDate,
ISNULL(resp.items.value('(PC:InsertBy)[1]', 'varchar(128)') , '')AS InsertBy,
ISNULL(resp.items.value('(PC:UpdateDate)[1]', 'datetime'), '12:00:00AM') AS
UpdateDate,
ISNULL(resp.items.value('(PC:UpdateBy)[1]', 'varchar(128)'), '') AS UpdateBy

    FROM         [dbo].[InProgress] CROSS
    APPLY ResponseXML.nodes('/PC:MasterResponse/PC:Action')
    AS resp(items)

All tables are located in the Database project in Schema Objects > Tables.
All views are located in Schema Objects > Views.

If there's any other information you need, please let me know.

Thanks very much.

Signature

Dave

> Hello Dave,
>
[quoted text clipped - 21 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
WenYuan Wang [MSFT] - 14 Jan 2008 11:37 GMT
Hello Dave,
Thanks for your reply.

I tried to create table and view on my side by the script you pasted. But,
I got an error message reads "Collection specified does not exist in
metadata : 'dbo.MasterResponse'". It seems the table which we want to creat
refer to another table named dbo.MasterResponse. I failed to create the
table so far.

By the way, there are many different database projects in VS 2005 DB Pro,
such as SQL Server project, SQL 2000 project, SQL 2005 project and Database
project. Could you please let me know which template of database project
you are working with. I have tried with Database project, but I cannot
found Schecma objects. Am I missing anything here?

To date, we cannot reproduce the issue. I would appriate if you can send me
your database file and the problematical database project. (my email
address is v-wywang@microsoft.com) This will help on repro very much.

Please feel free to let me know if you have any more concern. It's my
pleasure to asssist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Dave - 15 Jan 2008 16:15 GMT
WenYuan-

Thanks again for working on this for me. It appears that I have found a
solution.

I downloaded and installed the VS 2005 Team Edition for Database
Professionals Service Release 1. Although the descriptions for this update do
not seem to describe the exact problem I'm having, I went ahead and gave it a
try.

After installation, VS 2005 converted my project. Then I was able to build
and deploy the project successfully. The generated SQL script was created
with the tables and views in the correct order.

So, that takes care of the problem.

Thanks again.

Signature

Dave

> Hello Dave,
> Thanks for your reply.
[quoted text clipped - 25 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
WenYuan Wang [MSFT] - 16 Jan 2008 09:22 GMT
Hello Dave,

You are welcome. I'm so glad to hear you resolved the issue. It sounds VS
2005 DB pro Service Release 1 addressed the issue. Thanks for your
feedback. Others may get benefit from your reply. :)

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.