Question

I am learning Visual Studio 2012's "database project" system, using Visual Studio 2012 with Update 1, plus SSDT.

I am finding it very good at finding real problems in my database, especially programming errors in stored procedures where someone has removed a field from a database table but didn't go through and verify that all the stored procedures execute without errors. So validation of your .sql scripts via the "build" command in Visual Studio 2012 is very handy. I would hate to abandon it.

But I also note that whenever a #TEMPTABLE is used in a stored procedure, even when "Enable Extended Transact-SQL verification for common objects" is turned off, I still get "build errors" involving #temptable.field references in stored procedures.

What steps does the Database Project take to determine the schema of a temporary table? Since my temporary tables by definition don't exist in the main schema, they didn't get into my Database Project when I imported a real production SQL database into Visual Studio via the Import Database option, right after creating the database.

Should I be creating "#TEMPTABLE.SQL" files and adding them to my project?

Sample error:

c:\dev\...\dbo\Stored Procedures\xyz.sql(95,96): Warning:  SQL71502: Procedure: [dbo].[proc123] has an unresolved reference to object [#temptable1].[somefield1].

If there was a way to include a script that defined the temptables in use once, and include it into the various places where it's necessary to know about these if the T-SQL is to be thoroughly validated, that would be fine, and if Turning of Extended Verification did what I think it's supposed to do, then perhaps nothing would be necessary.

Forum post suggests this isn't possible to fix and that all I can do is effectively turn off this warning at a file level, which is kind of horrible.

A question on this same subject but for Visual Studio 2010 suggests that this is an area where this technology has been just flat out broken and Microsoft has known for years about it and done nothing about it. Is anything better now in VS2012.U1+SSDT_Dec2012?

Was it helpful?

Solution

Thats a problem with temp table, you should use table valued functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top