VS 2010 build database project receive SQL04151
Asked Answered
A

4

13

I just started working with the Visual Studio 2010 Premium database project. I must say it does indeed rock. One thing I can't figure out is how to avoid the SQL04151 warning

Procedure: [dbo].[MyProc] has an unresolved reference to object [MyDatabase].[dbo].[MyItem].

Did I miss a simple step somewhere? All I can find online involves tempdb.

Assiduous answered 2/4, 2010 at 18:57 Comment(1)
If [MyDatabase] is the same database where [dbo].[MyProc] is located it might be more advantageous to remove the [MyDatabase]. (or [$(DatabaseName)].) prefixes. If you install multiple instances on the same server for say, testing or development environments, you will not get expected results and may not even realize it, because references may be broken or work when referencing the wrong instance.Gremlin
A
14

I need to substitute [MyDatabase].[dbo].[MyTable] with [$(DatabaseName)].[dbo].[MyTable]. This cleared up the warnings.

Thanks for your help.

Assiduous answered 5/4, 2010 at 14:33 Comment(2)
Marking this item as the correct answer will move it to the top of the page, which will make it easier for others to find later.Pretext
Experienced exactly the same problem, this solved it, thanks.Floret
D
3

In your [dbo].[MyProc] procedure you reference [MyDatabase].[dbo].[MyItem] which is probably not part of your DB project. Even though the object exists in the DB, it is not known to Visual Studio during compilation and thus yields an error.

Normally you should have the entire DB-schema in the DB-project. Otherwise I think there is something called "partial DB projects" that you can look into.

Delft answered 2/4, 2010 at 19:5 Comment(1)
Actually all objects are part of the DB project. The stored procedure is in MyDatabase. I accepted the defaults when I created the project, but I expect I missed something along the way.Assiduous
F
2

MS has acknowledged this as a bug they are working on:

https://connect.microsoft.com/VisualStudio/feedback/details/543657/4151-unresolved-reference-warning-for-tempdb

Fordo answered 2/7, 2010 at 13:2 Comment(2)
The link is broken. Please remove the ?wa=wsignin1.0 from the end of the URL.Fiester
I can't see how this is related? The OP did not mention tempdb.Hierodule
O
0

Check you have set Build Action to Build on Properties pane for the specified object..

Otes answered 1/3, 2012 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.