I am trying to take a legacy database that is now on SQL Server 2008 R2 and create a database project within Visual Studio 2010 for it. There are several stored procedures that used some "on-the-fly" temp tables (the kind where you SELECT * INTO #NewTempTable) Obviously this causes some SQL04151 reference warnings in the database project.
Is there any way to fix or just maybe ignore these specific warnings? I know the immediate answer might be to actually declare the temp table within the procedure and define the columns, but at this point, that isn't an option.
This does not appear to be an issue with the latest database project type for VS 2010, installed as part of SQL Server Data Tools.
Try to install SQL Server Data Tools. After it's installed you'll be able to upgrade your database project to the new type by right-clicking it in Solution Explorer. (The new project type is backwards compatible with SQL 2008 and SQL 2005 and also comes with some significant improvements.)
FYI the new project type has a very generic name of "SQL Server Database Project" and you'll find it in the "SQL Server" template group as opposed to the "Database > SQL Server" group.
Turn SET FMTONLY OFF in your stored procedures.
From MSDN:
Returns only metadata to the client. Can be used to test the format of
the response without actually running the query.
Your issue is that by default Visual Studio has this setting turned on... which allows it to determine the format of the response without running the query, but this doesn't work if temp tables are used.
Here's a discussion of this issue on MS Connect: Improve FMTONLY Intelligence
Per Microsoft's response, this is fixed in 2012, but won't be addressed in earlier versions.
Lastly, here's a related discussion on the FMTONLY issue.
Related
I have a .NET project. When I do a SQL Server Schema Compare between what is on a local SQL Server 2017 database to Visual Studio in the direction of Database --> Project, the compare lists all tables, views, procedures and functions that are in the database under "Add".
It is unable to see the database objects in the project, so it thinks it needs to add everything to the project. Nothing shows in the Target object definition panel for any of the listed objects
If I do go ahead with the update to add a table to the project, E.G. Exhibit table, then it appears as Exhibit_1.sql in the project alongside the existing Exhibit.sql.
However, some changes were made to procedures in the database that showed up under "Change" so I was able to update them as normal
If I reverse the direction of the compare to Project --> Database, it lists all of the objects under Delete
Local Database is SQL Server 2017 but was upgraded from 2008.
Compatibility level is set to 2017 in the database properties in SQL Server Management Studio
In Visual Studio I have set the Target Platform of the database to SQL Server 2017.
I have ticked "Validate casing on identifiers" and Database collation is SQL_Latin_General_CP1_CI_AS on both
Visual Studio is version v15.7.1 and .NET is 4.7.03056
Is there anything else I need to do for the SQL Server Schema Compare to show the correct comparison? Something in the comparison settings?
I'm using Visual Studio 2010
In my project I was added a local database Data.sdf
Now I wanna use LINQ TO SQL with it, but when I drag and drop the database table into the LINQ designer , I get the following error in Visual Studio :
"The selected object(s) use an unsupported database provider"
Am I miss something ?
How can I fix it ?
LINQ-to-SQL is only officially supported when used with a full version of Microsoft SQL Server (including Express editions). While it's possible to use it with SQL Server CE (which is what it appears you're trying to do) and some others, extra steps are required.
You can either:
Use SqlMetal.exe to generate your .dbml file, then load it into your project (assuming you're using SQLCE 3.5; it doesn't appear to work with 4.0)
Keep an identical copy of your database schema in a SQL Server Express database on your local machine. Use that for design work, then connect to your SQL CE database at runtime.
Geometry, Geography and Hierarchy data types are not supported in LINQ to SQL.The only way it would be to not reference those columns and modify them so they can hold null values
I had this issue but it was resolved after installing the EntitiFramework package from Nuget.
ppm> install-package EntityFramework
I can't see to find a quick explanation of the differences so I can figure out which to use.
One is for a server one is for a Database? Im not sure what that means..
Basically we are doing a new web app and I want to see what these project types can offer me in terms of tracking the DB code/schema etc..
SQL Server 2008 Project: this is used to create a SQL-CLR module, e.g. create a stored proc, a function, an aggregate etc. in C# (or VB.NET), that will be run inside SQL Server.
When you create such a project, and you click "Add New Item" in Solution Explorer, you're given the choice of creating a stored procedure, a trigger, an aggregate, a user-defined function, a user-defined type or a helper class. These will all be compiled into a .NET assembly, which will be deployed to SQL Server and be executed inside SQL Server in the SQL-CLR runtime environment.
SQL Server Database Project: that's only a collection of SQL scripts to be run against a database, to create and manipulate database objects
In a SQL Server Database Project, you basically only get to add SQL scripts - .sql files. Nothing else, really. So it is indeed quite different from the SQL Server 2008 Project type!
The answer here doesn't seem to actually answer the posted question. "SQL Server 2008 Server Project" "SQL Server 2008 Database Project" are both things that exist in Visual Studio 2008 Database Edition, but sadly while there isn't one named "SQL Server 2008 Project" as the answer suggests, there is one "SQL Server Project" that matches the description. Moreover, there isn't a project type anymore called "SQL Server Database Project" (at least not in Visual Studio 2008 Team Suite), although the description given above seems to describe the much older database projects that were at one point available in VS.
After thinking about it further, I'm going to guess that marc_s doesn't have the Database Edition (otherwise known as Data Dude or DBPro) installed. Correct me if I'm wrong.
Sql Server 2008 Database Projects and Sql Server 2008 Server Projects seem to do basically the same thing. I would have hoped that the Server projects would be used for the installation and configuration, and change management of a Sql Server instance, while Database Projects would be used for individual databases inside them...but this doesn't seem to be the case. Has anyone actually been able to determine the differences between them?
After playing around for a bit, the only difference I've been able to find is that Sql Server 2008 Server Projects will always deploy to the master database on the server you deploy to, regardless of what kind of database you import (master or otherwise) when you create the project. So in that case, Database Projects are for your business databases while Server Projects are specifically for the master database on the server that houses your business databases.
Edit: After scouring the VS2008 documentation a little harder, I came across this specification:
"Deploying Server Projects
A database project can contain definitions for database objects, for server objects, or for both. In most environments, developers can change database objects, but only the database administrator can change server objects. You can enforce this restriction by putting server objects in a separate project (known as a server project). You can then restrict version control so that only your administrators can change the server project. In a staging or production environment, the server project and its objects will most often be deployed separately from the project that contains the database objects.
You deploy a server project by using the same procedures that you use to deploy a schema project."
http://msdn.microsoft.com/en-us/library/dd193413.aspx
I have Visual Studio 2010 Beta 2 and SQL Server 2008 installed. I'm working with a populated database and want to modify various column types. SQL Server Management Studio requires me to drop tables to do this, and get pretty finicky given my moderate level of knowledge of SQL Server.
However, I heard the new database project type supports changing the database schema to the desired format and it will handle creating and running all the scripts to implement the changes.
I've created a VS2010 database project using the existing database as the source, but so far haven't had much luck figuring out the appropriate method to make the changes without getting an error.
As a result, I'm looking for any reference info I can find on using VS2010's capabilities in this area. Any suggestions?
write scripts instead of using the gui. You can use alter table for instance to change a column. Never use a GUI of any kind to create a change to a database table.
Here's a walk through of the new VS2010 "Deploy-SQL" tab in the properties page of web application projects.
I need to migrate Access databases to SQL Server 2005. Since this needs to be done from within a setup so that a customers' installation is transparently migrated to SQL Server 2005, I wonder if it is possible to automate the SSMA toolkit from Microsoft.
Actually SSMA had command-line interface (special console executable in the SSMA installation folder). It was available at some time but I'm not sure whether it made its way to last release. You should ping SSMA support about what versions had it and what examples of its usages are available. I hope this will help you.
To my own knowledge, such an automation is not available. But it is still possible for you to generate the SQL code that creates the database (the one that will begin with the "CREATE DATABASE" sentence) and launch it through your user interface on your SQL server.
To generate this code, you can
Create the access database with the Access toolkit
Generate the corresponing "CREATE DATABASE" SQL code with (for example) SQL Server Management Studio (right-click on database, choose "script database as CREATE". EMS SQL Studio offers a very nice alternative to SQL Server Management Studio
Save the code for further use
With EMS Studio, You can even decide if this code also updates the data. But I'd prefer to automate data transfer through code: you can for example browse the tables (in the right order, depending on relationships), open recordsets (one local, one SQL), and transfer data by browsing the fields (you do not even need to name them) with code like:
(localRecordset links to local table. can be DAO or ADODB; Adjust code accordingly)
(sqlRecordset links to the SQL server. can be DAO or ADODB; Adjust code accordingly)
localRecordset.moveFirst
Do while not localRecordset.EOF
sqlRecordset.addnew
For each field in localrecordset.fields
sqlRecordset.fields(field.name).value = field.value
Next field
sqlRecordset.update
localRecordset.moveNext
Loop