DB Engine :: Migrate Table Data When Dealing With Constraints
Nov 19, 2015
I need to script out data in several tables (30+) and then reload those tables on a different database. Â The "target" database table data will get overwritten each time, not appended to. Â Several of these tables have numerous foreign keys and other constraints that must be dealt with. Â None of them have more than 100 records or so. Â Then I need to keep this script in source control and reference it as part of a post-deployment step with a Visual Studio DB project.
I have redgate, dbghost and visual studio. Â Are there any tools will generate the script for me complete with dropping all the constraints, truncating the tables, then re-adding the constraints back? Â Or, am I looking at simply scripting the table data out, then modifying the script myself to add in the steps to drop/readd the constraints? Â Further, since some of these tables might have relationships, not just to other tables, but to those in question, there will likely be an order in which the tables need to get loaded.
The approach I am thinking will be needed, since ive done this sort of thing before except with SSIS, is to run something like dbghost or the "generate scripts" option in SSMS as a starting point. Â From there, change the order around as needed, etc. Â
I am in process to migrate some replicated SQL 2008 databases to SQL 2012. I haven't migrated the replicated/mirrored databases yet however I have migrated some clean databases just having SSIS. This time I am tasked to migrate replicated one. providing  the detail steps to follow to migrate such databases?Â
I have to migrate all objects alogwith all constraints,SP,Triggers, indexes etc from Development instance to Production instance of a DB, all those things are created through wizard ie. Sql server 2000 Enterprise Manager. if i use DTS it only mirates data along with tables and views but constraints,SP,Triggers, indexes etc not yet copied.
can any body help me how can I solve this problem by copying all objects alogwith all constraints,SP,Triggers etc from Development instance to Production instance.
We are looking to store a large amount of user data that will bechanged and accessed daily by a large number of people. We expectaround 6-8 million subscribers to our service with each record beingapproximately 2000-2500 bytes. The system needs to be running 24/7and therefore cannot be shut down. What is the best way to implementthis? We were thinking of setting up a cluster of servers to hold theinformation and another cluster to backup the information. Is thispractical?Also, what software is available out there that can distribute querycalls across different servers and to manage large amounts of queryrequests?Thank you in advance.Ben
Christine the Pharmacist writes "Please pardon as I am not horribly advanced with SQL...
Using SQL Server 2000, Windows 2000, Service pack 4
I'm trying to figure out marketshares for "preferred" products. I have a table put together by hospital and month of medication use with the totals of each drug dispensed in columns as well. (example table below)
Hospital Month Drug A Drug B Drug C Drug D A 7 5 10 58 73 B 7 NULL 26 98 43 etc.
** Drug C and Drug D are the preferred drugs
I'm getting correct preferred % in all cases except when a value is NULL (result is NULL). I'm using an aggregate (sum), which should ignore NULLs, but it ignores NULLs within a column, and not ignoring across columns. I've tried setting concat_null_yields_null off and I'm still getting NULL (since I'm using the plus sign).
This is my admittedly confused select statement, suspect this is where my problem lies (problems with saying "sum", but using "+" as well?):
select a.Hospital,a.month,convert(float,sum(c.Drug_C+d.Drug_D))/convert(float,sum(a.Drug_A+b.Drug_B+ c.Drug_C+d.Drug_D)) as preferred_share
Hi, I have an SSIS package that runs each day from a live data source to create a data mart, which is then used for various things including SSAS and SSRS.
The problem is that certain records that will eventually go on to form fact tables are deleted from the live system (not a very robost database in the first place, hence the SSIS!) but these are not reflected in the SSIS transformation, creating plus figures when compared to the live system.
I currently use type 1 slowly changing dimension processes in each data flow (of which there are about 35) but I realise that this only updates records and does not delete.
The solution I have in place is to truncate the fact tables in the mart before the run starts using an Execute SQL task. This solves the problem though to me seems a little heavy-handed and renders the slowly changing dimension processes redundant (as it is currently only run once a day).
My question is, is there a better method of dealing with the above scenario? If there isn't, it would be a nice feature to add to future versions (*nudge nudge*).
I have an Excel file with .csv extension . it has on sheet with name Sheet1.
Now, I'm trying to insert this Excel data into one #temp table. I tried with syntax:
---------------- Exec sp_configure 'show advanced options', 1; RECONFIGURE; GO Exec sp_configure 'Ad Hoc Distributed Queries', 1; RECONFIGURE; GO EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1;Â
[Code] ...
But, I'm getting error:
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error.
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
If I'm executing for .xls file this statement is working finr and rows are inserted into #temp table. How to take excel file of .csv extension??
When I run:select * from testtableI get this error message:Invalid object name 'testtable'.However, if I run:select * from testuser.testtableIt works. I'm logged in as testuser, and testuser is the databaseobject owner and tableowner. This was a restored database from adifferent server in SQL Server 2000. The testuser login was in theprevious database. I created the same login in this new test databaseand made it database owner.I've also tried running: sp_change_users_login 'Update_One','testuser', 'testuser'It completed successfully but I still get:select * from testtableInvalid object name 'testtable'.I've also tried creating a different user and making it database ownerand when I change table object owner to this new user, I still get thesame problem. I need to specify:select * from newtestuser.testtableEven though I'm logged in as newtestuser.I also then tried changing table owner to dbo. This seems to worklogged in as either user, but I want to have the tables owned by theuser not dbo. How can I resolve this?Any help would be appreciated.Erin
I know this is probably a flick of a switch but I cannot figure out which switch. Setup is SQL Server / Stored Procedures / DAL / BLL(skipped for testing) / PL. The stored procedure queries from only one table and two columns are ignored because they are being phased out. I can run the stored procedure and preview the data in the DAL but when I create a page with an ODS linked to the DAL and a GridView I get this error. I checked every column that does not allow nulls and they all have values. I checked unique columns (ID is the only unique and is Identity=Yes in the table definition). I checked foreign-key columns for values that are not in the foreign table and there are none. Any ideas why do I get this? Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Hi, I am getting the above error when trying to load a report into my Web Application, I have tracked the error down to one specific field in my database. Even though this field is a NVarChar field and is of size 30 it would seem that there is an issue returning the value from the field. I can write it into the database no problems but when I try to get it out of the database it returns the above error. e.g MOB 401.908.804 - Fails 0401.907.324 - okay 8239 9082 (pager) - fails Anyone got an idea on how to fix this???? Regards.. Peter.
I have a requirement to delete 1 Million records from a table having 10 Million data and it's being queried on 24/7 basis (don't have a downtime). how can I achieve that?
I am unable to the access on table even after providing the SELECT permission on table.
Used Query by me :
Here Test is schema ; Card is table ; User is Satish
To grant select on Table
GRANT SELECT ON TEST.Card TO satish Even after this it is not working, So provided select on schema also. used query : GRANT SELECT ON SCHEMA::TEST TO Satish.
Migrate an Informix table (and eventually an entire database) to MS SQL Server 2012. This is my first experience using SSIS. I started off using the SSIS Import/Export Wizard to create a package. I was actually able to successfully copy a table, but it just didn't copy all the data. It skipped all the data that was in string columns. It created the columns with the proper datatype in the destination table, it just didn't copy the data. The other columns all copied properly. I need to do to get the string column data to copy?
hi all, i am having a requirement in which i have to migrate data that falls within a specified range to access table. i have to do this by creating a stored procedure that needs to run once in a week. can i perform this through a stored procedure or is there anyother way to perform this task. please advice.
i have to migrate data from one sql server(1) to another sql server(2) using SSIS,Which is a bit easy,the concern here is that after doing it the data in server(1) is getting updated due to inserts,now i need to bring the updated data alone.Is anybody having experience in this?can anyone pls help me or give me sugessions on how i need to proceed.
Can anyone recommend a good article/book on the subject? I am trying to find out more about compound primary keys. How many is “too many”? Does the number of primary key columns affect your performance? If so, how does it affect it? Should some of the constraints be handled from stored procedures?
I am new to MsSql. I want to know is there any command through which we can get all the consraints on a table or in a databases. In the same way how to get the all table names in a database from the coomand prompt or thorugh query analyzer.
Hi All, We will replace our website which currently build in php and mysql into .net and sql server 2005. What is the best way to migrate all the user account from current database in mysql into sql server, also considering that there is different database table and fields? Thanks in advance.
Hi Everybody, does anyone know how I can migrate SQL 2000 data to SQL 2005 database? I'm trying to create an application that will connect to SQL 2000 database using VS2003 and transfer data to SQL2005 database but it doesn't seem to work. Any suggestion is greatly appriciated. devmetz.
I have to migrate SQL Server 7.0 data to SQL Server 2000. How to go about doing this migration. What are the steps? Any pre-requisit before doing the migration?
Is there any book or KB articles or White paper on this topic on the net.
I m a new DBA I have a problem I have a SQL Server with 300 Databases on a machine. Now company has bought new Machine How to migrate data from old server to this new machine without recreating logins can some one help
I am attempting to populate an empty table from a csv file. I tried to use BULK insert but i got an error saying it wasn't supported. I am using Visual Web Developer 2008 Express Edition and I am using the query window. If someone can direct me to a link, or give me the simple sql script to do it, that would be most appreciated. Thanks in advance!
This is an SQL Server 2000 question. Without having access to the "Design Table" option in the pop-up menu of a table, is there another way to see what constraints, indexes, primary key, etc. that a table has?