Rename live production Database - sql-server

I have database in SQL Server called 'XYZ'. Now I want to change it to 'ABC'.
The problem is that my SSRS reports and SSIS packages are connected to the XYZ.
Everything that I have build SSRS reports & SSIS is now live, users using this Reports 24/7.
Is there any way to rename database with minimum/without any server/database downtime?
Thanks

Here's a Rube Goldberg approach:
Create a new, empty database that has the name you're ultimately intending on renaming your current database to (in your example "ABC")
Create a synonym in your new database for every object referenced by your SSIS packages and SSRS reports that uses a three-part name as the target. For example: create synonym [ABC].[dbo].[myTable] for [XYZ].[dbo].[myTable]
Update your packages and reports to point to the new database.
Under cover of darkness, rename ABC to ABC_drop and XYZ to ABC.
Drop ABC_drop.
It doesn't eliminate downtime, but does give you time to update all of the report and ETL package references. The rollback is also simple before step 5.

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 search SSIS Projects for references to specific tables?

Situation
In my new role, I need to check the ETL logic that is populating several of our tables. We deploy SSIS projects to manage our ETL workflow. Often we get feedback that a specific column may not have the expected data. In that situation, I will examine the ETL logic to make sure we are bringing the data correctly.
Complication
It is very time-consuming for me to identify which SSIS projects populate certain tables. We have many SSIS packages.
Question
Can I write a query to search the Integration Services Catalog (SSIS Projects) for a table reference?
Our SSIS Projects are stored in a separate database in a folder called Integration Services Catalog. Packages are not stored in the msdb system database.
SELECT
f.NAME AS FolderName
,sib.description
,sib.name as ProjectName
,sib.created_time
,sib.project_id
FROM [SSISDB].[internal].[projects] SIB
INNER JOIN internal.folders F ON F.folder_id = SIB.folder_id
I have found information about the projects but I can't see any XML, or code to search for table references. Also, I know I could search the SSIS project with Powershell, but it seems these are all stored on the server and I have no idea how to find the files to search from PowerShell.
We use SQL Server 2016.
The table references will be inside the XML of the SSIS Package. If you right click on a .dtsx and select edit with notepad++, this will open the xml and allow you to see what is being called. A quick way of doing this to go into you windows search box, type in 'Indexing Options', add the folder where your SSIS solutions are being held, go to advanced options select 'file types' and change the type of index to 'Index Properties and File Options'.
Now when you go to the Folder and type in the table name of the offending column the affected packages will appear. The only thing with this method is if you have some EXECUTE SQL TASKS that are just EXEC usp...xyz. It won't find the table name. You would then need to index the .sql of the saved stored procedures to see if that table name is referenced.
Hope this helps.

SSDT SQL Server Data Tools Customer specific requirements

We are using SQL Server Data Tools (SSDT) to manage our customer databases.
In theory all databases are identical, but in practice we have a few stored procedures (and one trigger) that would change from one customer to another.
We created a main SSDT for everything common, and then one SSDT per customer containing only the specific stored procedures (no tables).
In the specific SSDTs we get warnings because SSDT can't find the tables referred in the stored procedures, but we can live with that (obviously SSDT won't be able to validate the table's fields since it can't find the table). For the trigger, we get an error (table can't be found), thus the database project doesn't compile.
How should we manage that? I guess we should not be alone in this situation.
Is there a way for a database project to refer objects (tables) from another database project ?
Thanks,
Yves Forget
Daniel N gave the right direction, I'll just explain. Let's say you have database project named DatabaseA which will contain the only objects that 100% match for every customer. Then you create another database project DatabaseB and include DatabaseA as "the same instance, the same database". In database DatabaseB you can add customer specific objects. Then you can create other database for other customer in a similar way.
IN SSDT you can add another database project or dacpac as a reference.
In the properties for the referenced project you will be able to set where the referenced database resides, same server same database, same server diff database etc
https://msdn.microsoft.com/en-us/library/jj684584%28v=vs.103%29.aspx?f=255&MSPPError=-2147217396

SQL Server: Take the contents of a table as a backup to be used in other table

I have the following situation:
In my production DB, i want to save the contents of a table to my local DB copy.
Example:
In my production DB DB_PRODUCTION: i have the table Company with all the live data.
What I want to do is to copy the contents of the Company table into the Company Table of my test environment (that is located on a local server).
How can I do this without taking a complete backup of the DB_PRODUCTION database?
What I wanted to do is to perform a SELECT * FROM Company query on the production DB, save the result to .csv and import it in my DB_TEST database.
But is this even supported/Possible?
The version is SQL Server 2013 (Production) and SQL Server 2016 (Test)
Simply right-click on your source database and choose "Export..." from the context menu. The wizard will guide you through the process where you can select the desired source and target table(s) and options. If you want to maintain identity column values, make sure you activate this option.
The whole process also works the same way if you choose "Import..." on your target database.
As a bonus, you can opt to save the configuration for later re-use.

VS2010 database project deploy rebuilds every table

I have recently created a database project in VS2010 for an existing SQL Server 2008 R2 DB. I have updated 1 table out of 11 by adding 3 new columns to the end. I then updated 4 views that referred to that table.
I then tried a Build/Deploy with it only generating a script.
I have inspected the script and for every single table in the DB, it has generated code that will create a temp version of each table, copy the data from the existing table, drop the original and rename the copy.
I saw the posting on here where it insisted on rebuilding the table for dropped columns and I tried setting the IgnoreColumnOrder but it didn't make any difference. It didn't seem relevant to my situation, anyway, so I wasn't surprised.
I created my DB project by getting the DBA to give me a fully scripted version of Production, built that DB on my PC version of SQL Server and then created my initial project from that. I don't think that would make any difference and I have compared the project definition of the tables to the target Dev DB and they are the same.
I have "Always recreate database" unticked and "Block incremental deployment if data loss might occur" ticked. Don't suppose they have anything to do with my issue?
Any ideas?
I found a backup of the database and as per Peter's suggestion, ran a Schema Compare. The difference turned out to be that the target DB had PAGE compression on most of the tables but that was not in the project definition.

Resources