The model already has an element that has the same name - visual-studio-2010

I just created a new solution made up of two projects:
SQL Server 2008 Server Project
SQL Server 2008 Database Project
The Database Project has a Database Reference to the Server Project. When I try to build the solution I get three errors:
Error 291 SQL04105: The model already has an element that has the same name
dbo.sp_scramble
Error 292 SQL04105: The model already has an element that has the same name
dbo.sp_scramble.#Table.
Error 293 SQL04105: The model already has an element that has the same name
dbo.sp_scramble.#Field.
Both the Server and Database project were created by using the "Importing Objects and Settings..." option.
Also, the Server Project alone, builds without errors.
I'm using the project templates that shipped with VS 2010.
I guess my question is what caused these errors?
UPDATE: I fixed the errors by renaming the stored procedure, still I wonder what caused the error.

I fixed the errors by renaming the stored procedure.

Related

SSRS 2012 Shared SQL DataSource throws error on other workstations

I'm having a bizarre issue with SSRS 2012 reports, specifically with SQL Shared Data Sources.
My reproduction steps are as follows:
Create a new shared data source called Test, pointing to a SQL server on the network. Test credentials, get a successful test.
Create a new report called Test, not going through the wizard.
On the Test report, add the shared data source.
Add Dataset1 utilizing the shared datasource 'Test'. Query type of text as SELECT 1 AS 'one', 2 AS 'two'
Preview report. As expected, I get a blank report with no errors.
Commit data source and report to TFS repository (.rdl, .rds and changes to .sln).
Get latest on coworkers workstation
Open Test report, and go to Preview. The error I receive states 'An error has occurred during report processing.' Refreshing the report also gives error 'Object reference not set to an instance of an object,'
Recreating the shared data source on coworker's workstation lets the report run successfully again. Recommitting the changed data source then breaks the report on my original machine. The only thing changing in the .rds file is the DataSourceID, which is not referenced in the .rdl as far as I can see.
Both machines are on Visual Studio Premium 2013, with a SSRS 2012 solution file.
Any ideas as to what may be causing this are very much appreciated.
Cheers
For security, datasource credentials are not committed to source control nor propagated when deployed to a server. The first time you use the datasource in a new environment you will have to re-enter the credentials for the datasource to be able to connect to the database.

Unresolved Reference Error SQL71561 with SQL Server Data Tools 2010

I am getting an error when using SSDT 2010 (latest updates, v10.3.21208.0) with multiple database projects in a single solution. The error reads the following:
SQL71561: View: [dbo].[View] has an unresolved reference to object [OtherDatabase].[dbo].[OtherTable]
I've read all the other resources I could find on Stack Overflow and Google. Here are some things I've already tried:
Setup Database References to the other projects within the solution.
Cleared out the Database variable option to bypass the SQLCLR variable that dynamically changes your database name based on configuration options.
Ensured that Enable extended Transact-SQL verification for common objects is disabled on all projects
Have the Database location option set to: Different database, same server
Ensured the Project Build Order is arranged logically
Tried the suggestions from this post
Nothing seems to be working for me. Any help would be much appreciated. Here is a screenshot that might shed more light on my problem:
It has been a while, but I still want to share this solution with others that may be following the same lost links I was initially. Pay close attention to step 4. That cleared the issue for me.
A possible solution is to add a database reference to the database that has the missing object. The reference needs a Data-tier Application (dacpac file) that can be easily generated on the solution with the database project that has the missing object. Press the right mouse button over the database project and selected Snapshot Project. The dacpac file is created on the Snapshots folder. The file should then be copied to a common folder for re-usability.
In the project with the error press the right mouse button over the References and selected Add Database Reference. The Add Database Reference dialog appears:
Select the dacpac file
Select the database location. The most common option is "Different database, same server"
Confirm that the Database name field is as expected
Clear the "Database variable" field in the dialog. If this field has a value the queries must use this variable and not the database name
If the referenced database project builds, but the reference isn't resolving, try cleaning and rebuilding the referenced project and cleaning the project doing the referencing.
I'm using VS2015, but it might still apply. In my case, the referenced database had a "Database Variable Name" specified in the reference properties like $(SomeDb). If someone tried to refer to an item in the referenced database using the actual database name instead of the variable, we'd get a warning about an unresolved reference. Changing those to be like [$(SomeDb)].[dbo].[SomeTable] resolved the references.

VS2010 - SQL CRL Deploy error - Deploy error SQL04105: The model already has an element that has the same name

I have a SQL CLR project created in VS2010. It needs to run PreDeployScript.sql and PostDeployScript.sql. Both files exist in project. However, when trying to run the deploy, I get the following error messages:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlClr.targets(96,5): Deploy error SQL04105: The model already has an element that has the same name dbo.PropertySetCollection.
This message is repeated for every single type we have. This leads me to believe that PreDeployScript.sql was not run.
Has anybody else run into this issue? Is there a workaround?
Make sure you have not changed the Solution name. If you have you will now be out of sync with the assembly name on the SQL Server. To fix this just drop all the stored procedures for the existing assembly, drop the assembly, then try the deploy again. A new assembly will be created on SQL Server with the Solution name that is in VS.
Try using the Sql Proviler to check if the PreDeploy.sql has run.
Also read this:
https://connect.microsoft.com/VisualStudio/feedback/details/539211/db-projects-with-same-object-names-cannot-be-used-as-database-reference-error-sql04105?wa=wsignin1.0
It is a bug in VS2010 SQL CLR deployment. It has do to with dropping / adding computed columns in pre/post deploy scripts. MS is working on a solution.

VS 2010 Database Project bug?

I am having a very weird problem with building a SQL Server 2008 Database Project from within Visual Studio 2010. I created the database project and then imported the database objects and settings from a local database that I am working with. I then went to build the database project and got the following error:
SQL03006: View: [dbo].[GovCAStaff] has an unresolved reference to object [CTS_Staff].[dbo].[Client_Assignments].
The problem appears to be that the view GovCAStaff is referencing a table in a different database (CTS_Staff). However, I have numerous functions and stored procedures in the same database project that are referencing tables in a different database but the build process only generates warnings for those, not errors. Other than rewriting the view as a function, does anyone know of a way to get rid of this build error? Is this a known limitation of views within database projects? Anyway, I am really stumped. Have googled this topic and haven't found anything relevant. Any help would be greatly appreciated. Thanks in advance.
The reason this error shows up in views, but not functions and stored procedures, is because that is how SQL Server itself will react if the database/table does not actually exist. In other words, in SQL Server you can define stored procedures and functions that reference tables that don't exist or are otherwise inaccessible. Not so for views.
The way to resolve this issue is to add a 'database reference' (a .dbschema file) to your project so that the project build process knows about the schema of that other database. Where to get this magical .dbschema file?
Create another database project (presumably in the same solution) for the other database. This is most convenient, as you can just create a 'project reference' and everything stays up-to-date (you wanted a DB project for that other database, anyway, right?).
Create the .dbschema file manually via vsdbcmd.
If the database is a 'system' database (e.g. 'master' or 'msdb'), you can use one of the pre-built .dbschema files ({Program Files}\Microsoft Visual Studio 9.0\VSTSDB\Extensions\SqlServer{version}\DBSchemas).

How do you fix TSD02016 error in Database

I have a database I am using the Visual Studio 2010 Database Project tool vsdbcmd.exe to create a schema from.
vsdbcmd /a:Import /dsp:Sql /model:"Database" /cs:"Server=SqlServer; Initial Catalog=DatabaseName; Integrated Security=SSPI;"
The tool is reporting an error:
Error TSD02016, Gen-259 (12,50) The column name is not valid. No table name was specified.
How would I go about pinpointing where this error is originating?
I have found one resource on the internet (http://social.msdn.microsoft.com....) that points to a possibility of a keyword used incorrectly, but the error messages are not the same.
What is Gen-259?
Thank you,
Keith
I ran into a similar problem and was able to resolve it by using the import function in Visual Studio 2010. I created a new project and used Project -> Import Database Objects and Settings. In the our case, there were stored procedures that had become orphans and referenced columns in a table that no longer existed. We did have to correct some of the errors on the live system before we could get the project to fully import, but we were able to do that and create a .dbschema file which could be used as a reference in other VS projects.

Resources