Tables and stored procedures not getting included in the generated script - sql-server

I have created a SQL Server database project using Visual Studio 2015. The underlying database is SQL Server 2016. I have created the project by importing an existing database into the project. I have the structure ready. When I click on publish and select generate, it doesn't include the tables and stored procedures in the generated script. I can see one odd script added. Am I missing something?
Please see the screenshot of my project

The issue has been now resolved. The mistake i was making is importing the data objects from the database and trying to generate the script pointing to the same database. It was not generating the scripts since the database objects existed . Pointing to another database helped me generating the scripts.

Related

How to solve Acumatica SQL Error After Upgrade

I'm trying to update my client's Acumatica ERP to the latest version. I cloned the current instance to test drive the update procedure and make sure everything runs smoothly. They are currently using version 2019 R2 and want to update to 2020 R2.
Using the test instance, I updated it to the latest build of 2020 R2 and everything seems to be working except for one report. When I try to generate the Report I'm getting the following error.
I imagine this has to do with a change in the Database. However I can't find a table with that name either in the new database or in the current database. I'm not sure if that's table, store procedure, view, etc. I'm not very familiar with SQL.
I loaded the report in the report designer and try looking at the schema but couldn't find any reference to that particular table.
Any help would be greatly appreciated.
Regards.
CES
The SOAdjust table must exist in the database.
Please, try again with the following steps:
Create a snapshot of the client system.
Create a new system on the same version
Download and restore the snapshot created on the 1 point.
Download and install Acumatica 2020R2 ERP Configuration
Open the Acumatica ERP Configuration.
Select the system
For the upgrade procedure
7.1 Click the Update Only Database
7.2 Click the Update Only Website
In Acumatica 2019R2, the SOAdjust table is in two different namespaces.
PX.Objects.SO.SOOrderEntry.SOAdjust
PX.Objects.SO.SOAdjust
In Acumatica 2020R2, the SOAdjust table is in only one of them
PX.Objects.SO.SOAdjust
I think you should update the SOAdjust table in the report.
"view the namespaces in SQL Management Studio" - You don't. Namespaces are from .Net, and have to do with the code organization (crude description, but close enough for understanding). At a SQL level, the Acumatica structure is quite flat, just tables in the database (VERY few fancy sql tricks / sql level organization), all the "Real" logic tends to be in the business objects (Graphs, for the most part, though some interesting logic is within the DAC (data object classes))

How to import Table and Data to SQL Server Database Project in Visual Studio 2019

So, I have a solution file which consists of a ASP.Net MVC Application and a SQL Server Database Project. Both are checked in to TFS. I know how to import the database, table, views, functions and stored procedures, but I want to the tables to have data as well. How can I import the table with data?
You can define scripts to run as part of a sqlproj that will insert data into tables. I've seen it used for inserting basic configuration data.
In the Solution Explorer, right click your project and go to Add, then Script. Choose a Post Deployment Script or a Pre Deployment Script. Doing so will add a .sql file to your project, and set the build action appropriately so that it will either run before or after your schema has been created. In this case since you want to add data, you need a Post Deployment Script. If you need to control the order in which data is added, you can add it all in the same file, or just add a single post deployment script and have it invoke other .sql files.

SQL Server database project - Create change scripts

We started using SQL Server database project in Visual Studio 2012 by connecting an existing database. We are developing a web application that connects with this database.
Now we have around twenty stored procedures updated for the next release. How can I create a script file that contains only the updated stored procedures? We need to send this script to our clients along with the Web application executable files.
Is there any feature that allows us to compare and create only the changed scripts?
Thanks in advance!
Use Schema Compare as follows:
Create a Schema Comparison that compares the database project to one of the production databases.
Run the schema compare.
Exclude everything except for the stored procedures (plus any objects on which they depend).
Click Generate Script.
If you save this Schema Comparison then you can reuse it the next time you need to publish more stored procedure changes.

Visual Studio Database Schema Compare Adds not showing up

I'm setting up a new SQL Server Database Project for the first time using an existing database. I created my new project, then imported the database and it worked just fine.
However when I add a new stored procedures to my new Database Project and then do a Compare Schema to my local database, the Add of the new stored procedure doesn't show up.
To be clear, when running the Compare I'm setting my source to my Database Project and target to my local database.
The Compare Schema works great for modifications or deletions of stored procedure scripts in my Database Project just not when I define a new one. Am I missing something? Why don't new stored procedures define in my project show up in the comparison results?
I'm using VS2013, SQL Server 2008 R2.
It turns out when I created the stored procedure in Visual Studio I chose the Script... option instead of the Stored Procedure... option. The image below shows what I should have done.
Add the file as a Script resulted in the .sql file being added to a different ItemGroup in the project with no build properties. This is what caused the comparison to not pick it up as a stored procedure.
I determined this by looking at the properties of the .sql file (in Visual Studio) that I added and another .sql in the same project where the comparison worked. The file I added as a Script file had different properties than other files that were being treated as real stored procedures.
Moral of the story... make sure you add stored procedures in Visual Studio correctly.

Create Sql server 2008 Huge database script

I have a about 250 SQL script files included tables, stored procedure, user define function, triggers scripts.
I use these files to create and update old database. i want to enhance the time of creation cause it takes very long time to complete. is there more efficient way to create new database with all needed script indexes, triggers, views, SP, UDF.. or way to speed up the creation time.
Just import the scripts into a New SQL Server Database Project in Visual Studio and do a 'Deploy' of the Database Projects after setting up the connection strings properly.
See:
How to: Import Database Objects from a Script. and
Creating A Sql Server Database Project In Visual Studio 2012..
Are you using SQL Server Data Tools? These tools allow you to point your Visual Studio solution at a DB instance and it will generate you a Diff file, based on your DB projects contents.

Resources