Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 771439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:39:14+00:00 2026-05-14T18:39:14+00:00

I have a database project in my VS2010 solution. I recently changed a view

  • 0

I have a database project in my VS2010 solution. I recently changed a view and and changed a number of functions to use this view instead of going directly against a table.
But now when I deploy I get errors on most of these functions because the column asked for does not exists in the view yet.
The update of the view happends later than the update of UDF’s. Is there any way to change this behaviour?
Wouldn’t the best thing be if the deploy script updated in this order: tables, views, SP and UDF. It seems like tables is updated first, but the views are just thrown in somewhere in the middle of the deploy script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:39:15+00:00Added an answer on May 14, 2026 at 6:39 pm

    Since UDFs may be used in views, and views may be used in UDFs, it would have to analyse all of them to determine a coherent deployment order – it would have to parse all of the SQL. And who knows what it’s to do if you have dependencies on other databases.

    Edit

    There’s no documented/supported way to force a deployment order, so far as I can see. With some minimal testing, it appears to me that UDFs (at least table valued) are always deployed before views.

    Edit 2

    Even stranger, it turns out it does do the dependency analysis. Looking at the .dbschema output file for a db project, I can see it produces a <Relationship Name=”BodyDependencies”> element for the function, that does list the view/columns it depends on. But the deployment sql script still puts the view later on. Curious.

    Edit 3

    Probably final edit. I think, in general, that the problem is unsolvable. (Admittedly, the following only errors because I’ve specified schemabinding). If the old function definition relies on the old view definition, and the new function definition relies on the new view definition, there’s no right way to alter the database using ALTERs:

    create table dbo.T1 (
        ID int not null,
        C1 varchar(10) not null,
        C2 varchar(10) not null,
        C3 varchar(10) not null
    )
    go
    create view dbo.V1
    with schemabinding
    as
        select ID,C1,C2
        from dbo.T1
    go
    create function dbo.F1()
    returns table
    with schemabinding
    as
        return select ID,C1,C2 from dbo.V1 where ID=1
    go
    alter view dbo.V1
    with schemabinding
    as
        select ID,C1,C3
        from dbo.T1
    go
    alter function dbo.F1()
    returns table
    with schemabinding
    as
        return select ID,C1,C3 from dbo.V1 where ID=1
    go
    

    result:

    Msg 3729, Level 16, State 3, Procedure V1, Line 4
    Cannot ALTER 'dbo.V1' because it is being referenced by object 'F1'.
    Msg 207, Level 16, State 1, Procedure F1, Line 5
    Invalid column name 'C3'.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to do a subselect to find the max… May 14, 2026 at 10:24 pm
  • Editorial Team
    Editorial Team added an answer Not used it, but this showed up pretty quickly via… May 14, 2026 at 10:24 pm
  • Editorial Team
    Editorial Team added an answer It's about separation of concerns. Observers allow you to factor… May 14, 2026 at 10:24 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.