I have imported my sql server 2005 database into a VS2010 database project. One of my stored procedures contains a statement similar to
INSERT INTO #myTemp...
and Visual Studio gives me a warning such as
SQL04151: Procedure: [dbo].[mySproc] has an unresolved reference to object [#myTemp].
Is there a way of resolving this reference? I'd like to clear as many of the project warnings as possible.
I had the same thing, where the parent creates it. Instead of getting rid of the warning by creating the table if it doesn't exist, I want to be able to throw an exception if it doesn't. Putting a CREATE statement after the return statement guarantees that it will never get ran but also clears up the warning.
IF (OBJECT_ID('tempdb..#Foo') is null)
BEGIN
Raiserror('#Foo doesn''t exist.', 16, 1)
RETURN
CREATE TABLE #Foo (foo int) --Here just to get rid of compile warning
END
Did you try three part naming as in here (VS 2010 build database project receive SQL04151)
Also you might need to change the db ref to tempdb instead of master. See this article (http://blogs.msdn.com/b/gertd/archive/2009/06/10/system-objects-in-tempdb.aspx). It describes sys objects but temporary tables are stored in tempdb so would exhibit the same behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With