SQL Server Data Tools - Find all external references - sql-server-data-tools

I'm trying to create a DACPAC for an existing SQL Server database, but I am getting errors because of external references.
I'd like to try to get a full list of ALL the external references in SQL Server along with information about the stored proc/view where they are located.
Is there a query I can run in SQL Server (2017) to return this information?
EDIT: To clarify, I don't want to suppress the errors, I want them to be addressed, but I need the full list before I can proceed.

Related

I can't seem to create a SQL Server database with Visual Studio in data connections

I'm trying to create a SQL Server database and then to use it to make a list with important stuff in it. I don't seem to make it work. I went to the toolbox, chose panel and then when I get into creating the server itself, it doesn't work as it is not showing me a server name and the database name needed for it to work. I tried to write them myself but it's still not working.
Both of them when I open the list don't show anything. I understood that is essential for it to show me things for it to work.
You could install LocalDB through the Visual Studio Installer, as part of the Data Storage and Processing workload, the ASP.NET and web development workload, or as an individual component.
After you install it, you could get it directly.
Here is the full documentation about LocalDB.
You can also refer to this set of ssdt database operation process to learn database.

Copy some entries from one server database to other server database using asp.net mvc

We are doing some CRUD operation in DEV environment and data is saved in database. For other environments(like Staging/Prod) we want to copy those records from DEV database and paste to Staging/Prod when required using asp.net MVC. Is it possible? Could you please suggest some pathway in order to accomplish this?
You can accomplish this using a linked server:
https://learn.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine?view=sql-server-ver15
This involves creating a link between one database server and another (they must be able to see each other on the network). You can then reference the linked server like this:
INSERT INTO [LinkedServerName].[Database].[dbo].[Table] (......
Alternatively you could use a paid for tool like SSMS tools which can generate insert statements on a per table basis: https://www.ssmstoolspack.com/

Dynamic Data to external database asp.net

I'm stepping through a walk through which allows me to create a dynamic data website.
Though in all the tutorials, including the one above, they all point to a local file based database. I need to add an external data model.
How could I add an external data model to the project? (A database hosted on a seperate SQL Server)
I've tried connecting through the SQL Server Object Explorer then dragging it into App_Data, but that didn't work.
Use the connection string in the web.config, but as you add the EF data model you should be given the opportunity to select you database by browsing for it.

Creating Membership DB (ASPNETDB) on remote server?

I'm building a web application which soon I'll be promoting to production. This application has a login screen, as you know I used the integrated DB for developing. Now I want to move this database to a full SQL Server 2005. I'm using the aspnet_regsql.exe to create my membership tables and stored procedures in the SQL Server 2005 but I'm getting an error:
An error occurred during the execution of the SQL file 'InstallMembership.sql'. The SQL error number is 207 and the SqlException message is: Invalid column name 'FailedPasswordAnswerAttemptWindowStart'.
I google this for half of the day already and I can't seem to fine what's wrong, does anybody have ANY ideas on what am I doing wrong here? Any help will be really appreciate it.
The easiest way to deploy a brand new database to a remote server is to just publish the database from within Visual Studio. Once you do that you have the scheme and data all in one script. You then access your server either via a local SQL manager connection or a remote manager and run the script on your remote database.
The site 4GuysFromRolla has a nice little walk through with graphics which describe how to accomplish the publishing of your local database to your hosted one.
Good luck, and hope this helps you out some.
Go through the *.sql script file and see where that column reference is. Then you'll be able to see what exactly the script is doing to cause this error. My guess would be that it is getting caught up on referential integrity. If it is trying to create a foreign key constraint that that table/column does not exist then you'll see that error.
But back to the original question at hand. You don't need to recreate your whole database. That script file is to lay down the Membership for an empty database. If you have a working dev database you can just back it up and restore it to a production instance. No need to rebuild the membership database objects.

How to create a database and populate it during setup

I would like to find a way to create and populate a database during asp.net setup.
So, what I'm willing to do is:
Create the database during the setup
Populate the database with some initial data (country codes or something like that)
Create the appropriate connection string in the configuration file
I'm using .NET 3.5 and Visual Studio 2005, and the Database is SQL Server 2005.
Thanks in advance.
If you are creating an installer I'm sure there is a way to do it in there, but I am not all that familiar with that.
Otherwise, what you might do is the following.
Add a application_start handler in the Global.asax, check for valid connection string, if it doesn't exist, continue to step two.
Login to the server using a default connection string
Execute the needed scripts to create the database and objects needed.
Update the web.config with the connection information
The key here is determining what the "default" connection string is. Possibly a second configuration value.
Generally, you'll need to have SQL scripts to do this. I tend to do this anyway, as it makes maintaining and versioning the database much easier in the long run.
The core idea is, upon running the setup program, you'll have a custom action to execute this script. The user executing your setup will need permissions to:
Create a database
Create tables and other database-level objects in the newly-created database
Populate data
Your scripts will take care of all of that, though. You'll have a CREATE DATABASE command, the appropriate CREATE SCHEMA, CREATE TABLE, CREATE VIEW, etc. commands, and then after the schema is built, the appropriate INSERT statements to populate the data.
I normally break this into multiple scripts, but YMMV:
Create schema script
"Common scripts" (one for the equivalent of aspnet_regsql for web projects, one with the creation of the Enterprise Library logging tables and procs)
Create stored procedure script, if necessary (to be executed after the schema's created)
Populate initial data script
For future maintenance, I create upgrade scripts where a single script typically handles the entire upgrade process.
When writing the scripts, be sure to use the appropriate safety checks (IF EXISTS, etc) before creating objects. And I tend to make mine transactional, as well.
Good luck!
Well, actually I found a tutorial on MSDN: Walkthrough: Using a Custom Action to Create a Database at Installation
I'll use that and see how it goes, thanks for your help guys, I'll let you know how it goes.
If you can use Linq to Sql then this is easy.
Just import your entire database into the Linq to Sql designer. This will create objects that describe all objects in your database, including the System.Data.Linq.DataContext derived class that encapsulate the entire database setup.
Now you can call DataContext.CreateDatabase() to create the database.
See here more information.

Resources